Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config-server.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ RUN python3 -m pip install -v \
# prep app code
WORKDIR /code
COPY . .
CMD ["python3", "config_webserver.py"]
CMD ["python3", "src/config_webserver.py"]
3 changes: 0 additions & 3 deletions config_webserver.py

This file was deleted.

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ volumes:
services:

bitbot:
platform: linux/arm64/v7
#platform: linux/arm64/v7
privileged: true
restart: unless-stopped
network_mode: "host" # alows us to show IP address
Expand All @@ -23,7 +23,7 @@ services:
# - BITBOT_OUTPUT=disk, waveshare.epd2in7b_V2, inky

config-editor:
platform: linux/arm64/v7
#platform: linux/arm64/v7
restart: unless-stopped
build:
dockerfile: config-server.dockerfile
Expand Down
4 changes: 2 additions & 2 deletions docs/app_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Test the app
python3 -m run
```

Add cron jobs to start the [app](/run.py) and [config-server](/src/configuration/config_webserver.py) after reboot
Add cron jobs to start the [app](/run.py) and [config-server](/src/config_webserver.py) after reboot
```sh
(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/configuration/config_webserver.py") | crontab -
(crontab -l 2>/dev/null; echo "@reboot sleep 30 && cd /home/pi/bitbot && python3 src/config_webserver.py") | crontab -
```
36 changes: 20 additions & 16 deletions docs/device_usage.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
# 📈 How to configure your new crypto-watcher
# 📈 Configure your **Crypto Watcher**

## Physical setup
1. Remove the screen protector that is covering the e-paper display (there is a red tab at the bottom-left)
2. **Connect a micro-usb** cable 🔌 to the raspberry pi board on your crypto-watcher
3. **Wait a minute** ⌚ or so for it to boot up
4. The device will display a short **intro sequence** 📺 for you to follow
5. From another device, **connect** to the `bitbot-{nnn}` access point
- ⚠️ on mobile decives, you may need to disable mobile data here
6. if you are not automaticaly shown the config web page, open your browser and goto google.com. the page should then load.
1. **Connect a micro-usb** cable 🔌 to the raspberry pi board on your crypto-watcher
1. **Wait a minute** ⌚ or so for it to boot up

## First tine setup
1. A short **intro sequence** 📺 may be displayed (this only happens once)
1. From another device, *connect* to the `bitbot-{nnn}` **wifi access point**
- ⚠️ on **mobile decives**, you may need to **disable mobile data here**
1. if you are not automaticaly shown the config web page, open your browser and goto google.com. the page should then load.
- ⚠️ if this fails please use `http://10.41.0.1` in the browser url
7. Select your home **wifi access point name** 🛜
8. Enter your **wifi password** 🙈
9. **Wait** for the device to reboot ♻️ (this may take 1-2 mins)
1. Select your **home wifi access point name** 🛜
1. Enter your **wifi password** 🙈
1. **Wait** for the device to reboot ♻️ (this may take 1-2 mins)
* you many need to go **back to #5, or restart** the device if there's no action within **5 minutes**
* Your crypto-watcher will **refresh** the screen once it has **loaded up and connected** to the internet.
* The device is set up to **refresh** every **ten minutes**.
* The dispayed instrument defaults to **Bitmex BTC/USD**.
* The device is set up to **refresh** every **thirty minutes**.
* The dispayed instrument defaults to **Coinbase BTC/USD**.

> More detailed [instructions with screenshots can be found here](wifi_setup.md)

# ⚙️ Advanced Configuration
### Configuration for your crypto-watcher is stored in a `config.ini` file on the raspberry Pi
### Visit [http://bitbot:8080](http://bitbot:8080) in your browser to **edit the configuration**

- Visit [http://bitbot:8080](http://bitbot:8080) in your browser to **edit the configuration**
- Configuration for your crypto-watcher is stored in a `config.ini` file on the raspberry Pi
- Edit the config file directly see [💾 **Config** Options](docs/config_options.md)
- A list of **supported crypto-exchanges** can be found [here](https://github.com/ccxt/ccxt/wiki/Exchange-Markets)
- Please see your selected exchange for the ***instruments that it supports***

### Bitbot uses [Style Files](../config/mpl_styles/base.mplstyle) to control the chart layout.
### Bitbot uses **matplotlib [Style Files](../config/mpl_styles/base.mplstyle)** to control the chart layout.
- edit these if you're feeling experimental, Examples of the ***styling*** options can be [found here](https://matplotlib.org/stable/tutorials/introductory/customizing.html#the-default-matplotlibrc-file)

### Inky Impression **Button** support
### Inky Impression **Button** support
- toggle_picure_frame_mode
- refresh_display
- toggle_volume
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mplfinance>=0.12.10b0
watchdog==6.0.0
ccxt==4.4.40
inky==2.0.0
yfinance==0.2.51
yfinance==0.2.54
tzlocal
python-dateutil

Expand Down
4 changes: 2 additions & 2 deletions src/config_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pathlib
import time
import uuid
from src.configuration.bitbot_files import BitBotFiles
from src.configuration.bitbot_config import load_config_ini
from configuration.bitbot_files import BitBotFiles
from configuration.bitbot_config import load_config_ini
from flask import Flask, jsonify, render_template, request, redirect, send_from_directory, url_for
from PIL import Image
import ccxt
Expand Down
3 changes: 3 additions & 0 deletions src/config_webserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from config_server.server import app

app.run(debug=True, host='0.0.0.0', port=8081)
4 changes: 2 additions & 2 deletions src/configuration/bitbot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def read_dict(self, dict):

# 🌱 intro setup
def on_first_run(self, action):
if self.config["first_run"]['enabled'] == "true":
if self.config.get('first_run', 'enabled', fallback=None) == "true":
action()
self.set('first_run', 'enabled', "false")
self.save()
Expand All @@ -205,7 +205,7 @@ def intro_background(self):

# 📺 youtube subs setup
def youtube_subs_enabled(self):
return self.config['youtube_subs']["enabled"] == 'true'
return self.config.get('youtube_subs', 'enabled', fallback=None) == 'true'

def youtube_channelid():
return "UCAotflAHrgfuhK9Rw-C_-Ug"
Expand Down
21 changes: 13 additions & 8 deletions src/configuration/network_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .log_decorator import info_log
import socket
from .log_decorator import info_log
import http.client as httplib
import time


Expand All @@ -17,17 +18,21 @@ def get_ip():
return ip


def network_connected(hostname="google.com"):
def network_connected(hostname="8.8.8.8") -> bool:
# 📡 test if internet is available
conn = httplib.HTTPSConnection(hostname, timeout=5)
try:
host = socket.gethostbyname(hostname)
socket.create_connection((host, 80), 2).close()
conn.request("HEAD", "/")
return True
except Exception:
time.sleep(1)
return False

except Exception as e:
return network_error(e)
finally:
conn.close()

@info_log
def network_error(exception):
return False

@info_log
def wait_for_internet_connection(action):
connection_error_shown = False
Expand Down
2 changes: 2 additions & 0 deletions src/display/inky.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def show(self, image):
self.display.set_border(self.display.WHITE)
case "black":
self.display.set_border(self.display.BLACK)
case "red":
self.display.set_border(self.display.RED)

# 🌀 rotate/resize the image
image = self.apply_rotation(image)
Expand Down
3 changes: 3 additions & 0 deletions src/display/waveshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def show(self, image):
time.sleep(1)
epd.display(epd.getbuffer(black_image), epd.getbuffer(color_image))
epd.sleep()
except TypeError: # hax to deal with waveshare epd diver API variation
epd.display(epd.getbuffer(image))
epd.sleep()
finally:
self.lock.release()

Expand Down
Loading