Skip to content
Open
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
5 changes: 5 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM gitpod/workspace-full

USER gitpod

RUN pip3 install -U platformio && npm install html-minifier-terser -g
11 changes: 11 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
vscode:
extensions:
- vscode.cpp

tasks:
- before: platformio upgrade
- init: platformio test -e native
- command: platformio run -e lolin32

image:
file: .gitpod.Dockerfile
Binary file removed Boot.gif
Binary file not shown.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 lolwheel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# OwieWatcher
A simple ESP8266 based sketch to connect to an [owie](https://github.com/lolwheel/Owie) device and pull the battery info from the status webpage for output to an OLED display. The current code configuration outputs the Voltage, BMS SOC & OVERRIDEN SOC.
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/tonyt321/OWIE-OLED)

todo
- get gitpod working idk how to save from gitpod to here
- use the u8g2 library better display support

A simple ESP8266 based sketch to connect to an [owie](https://github.com/tonyt321/OWIE-OLED) device and pull the battery info from the status webpage for output to an OLED display. The current code configuration outputs the Voltage, BMS SOC & OVERRIDEN SOC.

## Demo
<br>OwieWatcher bootup</p>
Expand Down
1 change: 1 addition & 0 deletions lib/bms/desktop.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[LocalizedFileNames]
Binary file removed owie-watcher-logo_EXAMPLE.bmp
Binary file not shown.
192 changes: 0 additions & 192 deletions owie-watcher.ino

This file was deleted.

74 changes: 74 additions & 0 deletions pio_tools/gen_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Import("env")
import os
import subprocess

from SCons.Script import COMMAND_LINE_TARGETS

if "idedata" in COMMAND_LINE_TARGETS:
env.Exit(0)


def ReadAndMaybeMinifyFiles(fullPath):
_, extension = os.path.splitext(fullPath)
if not extension in ['.html', '.js', '.css']:
with open(fullPath, "rb") as f:
return f.read()
originalSize = os.stat(fullPath).st_size
result = subprocess.run(['html-minifier-terser',
'--collapse-whitespace',
'--remove-comments',
'--minify-js',
'true',
'--minify-css',
'true',
fullPath], stdout=subprocess.PIPE)
minifiedContent = result.stdout
print("Minified '%s' with from %d to %d bytes" % (fullPath, originalSize, len(minifiedContent)))
return minifiedContent


def GenData():
dataDir = os.path.join(env["PROJECT_DIR"], "data")
print("dataDir = %s" % dataDir)
genDir = os.path.join(env.subst("$BUILD_DIR"), 'inline_data')
print("genDir = %s" % genDir)
if not os.path.exists(dataDir):
return
if not os.path.exists(genDir):
os.mkdir(genDir)
env.Append(CPPPATH=[genDir])

files = sorted(file for file in os.listdir(dataDir)
if os.path.isfile(os.path.join(dataDir, file)))

out = "// WARNING: Autogenerated by pio_tools/gen_data.py, don't edit manually.\n"
out += "#ifndef OWIE_GENERATED_DATA_H\n"
out +="#define OWIE_GENERATED_DATA_H\n\n"
for name in files:
varName = name.upper().replace(".", "_")
sizeName = varName + "_SIZE"
storageArrayName = varName + "_PROGMEM_ARRAY"
out += (
"static const unsigned char %s[] PROGMEM = {\n " % storageArrayName)
firstByte = True
fileContent = ReadAndMaybeMinifyFiles(os.path.join(dataDir, name))
column = 0
for b in fileContent:
if not firstByte:
out += ","
else:
firstByte = False
column = column + 1
if column > 20:
column = 0
out += "\n "
out += str(b)
out += "};\n"
out += "#define %s FPSTR(%s)\n" % (varName, storageArrayName)
out += "#define %s sizeof(%s)\n\n" % (sizeName, storageArrayName)
out += "\n#endif // OWIE_GENERATED_DATA_H\n"
with open(os.path.join(genDir, "data.h"), 'w') as f:
f.write(out)
print("Wrote data.h\n")

GenData()
53 changes: 53 additions & 0 deletions pio_tools/platformio_upload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Allows PlatformIO to upload directly to AsyncElegantOTA
#
# To use:
# - copy this script into the same folder as your platformio.ini
# - set the following for your project in platformio.ini:
#
# extra_scripts = platformio_upload.py
# upload_protocol = custom
# upload_url = <your upload URL>
#
# An example of an upload URL:
# upload_URL = http://192.168.1.123/update

import requests
import hashlib
Import('env')

try:
from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
from tqdm import tqdm
except ImportError:
env.Execute("$PYTHONEXE -m pip install requests_toolbelt")
env.Execute("$PYTHONEXE -m pip install tqdm")
from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
from tqdm import tqdm

def on_upload(source, target, env):
firmware_path = str(source[0])
upload_url = env.GetProjectOption('upload_url')

with open(firmware_path, 'rb') as firmware:
md5 = hashlib.md5(firmware.read()).hexdigest()
firmware.seek(0)
encoder = MultipartEncoder(fields={
'MD5': md5,
'firmware': ('firmware', firmware, 'application/octet-stream')}
)

bar = tqdm(desc='Upload Progress',
total=encoder.len,
dynamic_ncols=True,
unit='B',
unit_scale=True,
unit_divisor=1024
)

monitor = MultipartEncoderMonitor(encoder, lambda monitor: bar.update(monitor.bytes_read - bar.n))

response = requests.post(upload_url, data=monitor, headers={'Content-Type': monitor.content_type})
bar.close()
print(response,response.text)

env.Replace(UPLOADCMD=on_upload)
Loading