Skip to content

Commit

Permalink
Merge pull request #149 from gyroflow/add-128x64-canvas
Browse files Browse the repository at this point in the history
Add support for 128x64 SSD1306 OLED
  • Loading branch information
DusKing1 authored Jul 20, 2022
2 parents 81793e3 + b2abd3a commit d70bf54
Show file tree
Hide file tree
Showing 55 changed files with 1,370 additions and 1,038 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
strategy:
matrix:
targets: [GENERIC, DIY_CARD, DIY_FC, NEUTRONRC_SDB]
targets: [GENERIC, G12864, DIY_CARD, DIY_FC, NEUTRONRC_SDB]
runs-on: ubuntu-latest

steps:
Expand All @@ -27,7 +27,7 @@ jobs:

- name: Build modules
run: |
python3 tools/build.py build TARGET ${{ matrix.targets }}
python3 build.py build TARGET ${{ matrix.targets }}
- name: Prepare esp-idf and micropython
run: |
Expand Down Expand Up @@ -55,5 +55,5 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: flowshutter-${{ matrix.targets }}-${{ github.run_number }}
name: flowshutter_${{ matrix.targets }}_${{ github.run_number }}
path: micropython/ports/esp32/build-GENERIC/firmware.bin
12 changes: 6 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ jobs:
- name: Build (check) SHA on Windows
if: ${{ matrix.targets == 'windows-latest' }}
run: |
python tools/build.py sha build
python build.py sha build
continue-on-error: false

- name: Build (check) SHA on Ubuntu
if: ${{ matrix.targets == 'ubuntu-latest' }}
run: |
python3 tools/build.py sha build
python3 build.py sha build
continue-on-error: false

- name: Build (check) SHA on MacOS
if: ${{ matrix.targets == 'macos-latest' }}
run: |
python3 tools/build.py sha build
python3 build.py sha build
continue-on-error: false

- name: Upload SHA
Expand All @@ -52,17 +52,17 @@ jobs:
- name: Verify SHA on Windows
if: ${{ matrix.targets == 'windows-latest' }}
run: |
python tools/gen_sha.py verify
python build.py sha verify
continue-on-error: false

- name: Verify SHA on Ubuntu
if: ${{ matrix.targets == 'ubuntu-latest' }}
run: |
python3 tools/gen_sha.py verify
python3 build.py sha verify
continue-on-error: false

- name: Verify SHA on MacOS
if: ${{ matrix.targets == 'macos-latest' }}
run: |
python3 tools/gen_sha.py verify
python3 build.py sha verify
continue-on-error: false
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ TBD
### Start debugging

1. Modify the `pymakr.conf` to match up with your flowshutter's COM port
2. `python tools/build.py debug` to prepare the debug environment (move modules to `/obj` directory)
2. `python build.py debug` to prepare the debug environment (move modules to `/obj` directory)
3. Upload all modules to the hardware and reboot it.

Note:
- `python tools/build.py debug`: copy modules to `/obj` directory
- `python tools/build.py debug clean`: clean the `/obj` directory. Useful when you are suffering from memory leak.
- `python build.py debug`: copy modules to `/obj` directory
- `python build.py debug clean`: clean the `/obj` directory. Useful when you are suffering from memory leak.

### Compile flowshutter firmware (single bin)

There's a CI that can help us to this. For compiling it locally, please check `tools/build.py` for more information.
There's a CI that can help us to this. For compiling it locally, please check `build.py` for more information.


## License
Expand Down
68 changes: 33 additions & 35 deletions tools/build.py → build.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@ def move(argv):
for file in files:
filepath = subdir + '/' + file
modules.append(filepath)
temp = {x.replace('src/','').replace('src\\','')
.replace('gui\\','gui/').replace('protocols\\','protocols/')
for x in modules}
modules = temp
temp1 = {x.replace('src\\','').replace('src/','')
for x in modules}
temp2 = {x.replace('gui\\','gui/').replace('protocols\\','protocols/')
for x in temp1}
temp3 = {x.replace('hal\\','hal/')
for x in temp2}

# temp2 = {x.replace('hal\\','hal/')
# for x in temp1}
modules = temp3
print(modules)

modules.remove('__init__.py')

if argv == 'COMPLIE':
if argv == 'COMPILE':
try:
# these files should/can not be compiled as frozen modules
modules.remove('boot.py')
Expand Down Expand Up @@ -64,9 +71,18 @@ def move(argv):
shutil.copyfile('src/'+f, 'obj/'+f)
print('CP '+f+' ..')
except FileExistsError:
os.mkdir(path='obj/'+f.split('/')[0]+"/"+f.split('/')[1])
shutil.copyfile('src/'+f, 'obj/'+f)
print('CP '+f+' ..')
try:
os.mkdir(path='obj/'+f.split('/')[0]+"/"+f.split('/')[1])
shutil.copyfile('src/'+f, 'obj/'+f)
print('CP '+f+' ..')
except FileExistsError:
os.mkdir(path='obj/'+f.split('/')[0]+"/"+f.split('/')[1]+"/"+f.split('/')[2])
shutil.copyfile('src/'+f, 'obj/'+f)
print('CP '+f+' ..')
except FileNotFoundError:
os.mkdir(path='obj/'+f.split('/')[0]+"/"+f.split('/')[1]+"/"+f.split('/')[2])
shutil.copyfile('src/'+f, 'obj/'+f)
print('CP '+f+' ..')
except FileNotFoundError:
os.mkdir(path='obj/'+f.split('/')[0]+"/"+f.split('/')[1])
shutil.copyfile('src/'+f, 'obj/'+f)
Expand All @@ -75,8 +91,8 @@ def move(argv):
try:
shutil.rmtree(path='obj/__pycache__')
print('RM '+'obj/__pycache__')
shutil.rmtree(path='obj/protocols/__pycache__')
print('RM '+'obj/protocols/__pycache__')
shutil.rmtree(path='obj/hal/protocols/__pycache__')
print('RM '+'obj/hal/protocols/__pycache__')
except FileNotFoundError:
pass

Expand All @@ -90,7 +106,7 @@ def build(argv1, argv2):
print('obj/ already exists')
pass

if argv1 == 'COMPLIE':
if argv1 == 'COMPILE':
# copy necessary modules
prefix_modules = os.listdir('build/')
print('..\nCOPY prefix')
Expand All @@ -113,6 +129,8 @@ def build(argv1, argv2):
source_address = 'obj/targets/diy_fc.py'
elif argv2 == 'NEUTRONRC_SDB':
source_address = 'obj/targets/neutronrc_sdb.py'
elif argv2 == 'G12864':
source_address = 'obj/targets/g12864.py'
else:
print('ERROR: target not found')
sys.exit()
Expand Down Expand Up @@ -153,29 +171,19 @@ def gen_sha(jdir):
if __name__ == '__main__':
if len(sys.argv) == 1:
# `build.py`
build('COMPLIE','GENERIC')
build('COMPILE','GENERIC')
else:
if sys.argv[1] == 'build':
# `build.py build`
if len(sys.argv) == 2:
print('Build started!')
build('COMPLIE','GENERIC')
build('COMPILE','GENERIC')
print('Build complete!')
elif sys.argv[2] == 'TARGET':
# `build.py build TARGET XXXX`
target = sys.argv[3]
print('Build started!')
if target == 'GENERIC':
build('COMPLIE','GENERIC')
elif target == 'DIY_CARD':
build('COMPLIE','DIY_CARD')
elif target == 'DIY_FC':
build('COMPLIE','DIY_FC')
elif target == 'NEUTRONRC_SDB':
build('COMPLIE','NEUTRONRC_SDB')
else:
print('ERROR: target not found')
sys.exit()
build('COMPILE', target)
print('Build complete!')

elif sys.argv[1] == 'debug':
Expand All @@ -188,17 +196,7 @@ def gen_sha(jdir):
# `build.py debug TARGET XXXX`
target = sys.argv[3]
print('Preparing for debug mode...')
if target == 'GENERIC':
build('DEBUG','GENERIC')
elif target == 'DIY_FC':
build('DEBUG','DIY_FC')
elif target == 'DIY_CARD':
build('DEBUG','DIY_CARD')
elif target == 'NEUTRONRC_SDB':
build('DEBUG','NEUTRONRC_SDB')
else:
print('ERROR: target not found')
sys.exit()
build('DEBUG', target)
print('Debug ready!')
elif sys.argv[2] == 'clean':
print('Performing clean')
Expand Down
8 changes: 6 additions & 2 deletions build/inisetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ def setup():
vfs = uos.VfsLfs2(bdev)
uos.mount(vfs, "/")
with open("boot.py", "w") as f0:
f0.write("import startup")
f0.write("import bootc")
f0.close()

with open("main.py", "w") as f1:
f1.write("import entry")
f1.write(
"""\
import gui.logic as logic
gui = logic.Logic()
""")
f1.close()

return vfs
1 change: 1 addition & 0 deletions pymakr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"open_on_start": true,
"safe_boot_on_upload": false,
"py_ignore": [
"LICENSE",
"pymakr.conf",
"__pycache__",
".vscode",
Expand Down
2 changes: 1 addition & 1 deletion src/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#esp.osdebug(None)
#import webrepl
#webrepl.start()
import startup
import bootc
13 changes: 7 additions & 6 deletions src/startup.py → src/bootc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
import time
print(str(time.ticks_us()) + " [ Boot ] Start")

from machine import Pin, SoftI2C
from machine import Pin, I2C
import framebuf
import gui.driver.ssd1306 as ssd1306
i2c = SoftI2C(scl=Pin(22), sda=Pin(21),freq = 800000)
screen = ssd1306.SSD1306_I2C(128, 32, i2c, True)
import hal.driver.ssd1306 as ssd1306
i2c = I2C(0,scl=Pin(22), sda=Pin(21),freq = 1000000)
import target
screen = ssd1306.SSD1306_I2C(128, target.oled_height, i2c, True)
gyroflow_bytearray = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xc0\x00\x00\x00\x00\xf0\x00\xc0\x00\x00\x00\x00\x00\x00\x00\x03@\x00\x00\x00\x01\x98\x01\xc0\x00\x00\x00\x00\x00\x00\x00\x06@\x00\x00\x00\x01\x0c\x01\xe0\x00\x00\x00\x00\x00\x00\x00\x0cA\x80\x00\x00\x03\x06\x03p\x00\x00\x00\x00\x00\x00\x00\x18\xc3\x00\x00\x00\x02\x02G0\x00\x00\x00\x00\x00\x00\x001\x87\x00\x00\x00\x1a\x01\xe68\x00\x00\x00\x00\x00\x00\x00!\x0e\x00\x00\x00r\xc3\xee\x18\x00\x00\x00\x00\x00\x00\x00c\x0c\x00\x00\x00\xc2O|\x1c\x00\x00\x00\x00\x00\x00\x00B\x18\x00\x00\x00\x83<8\x0c\x0f\xe3\x03?\xe0|\x00\xc4\x10\x00\x00\x00\x818\x18\x0e\x1f\xf3\x87?\xf0\xfe\x00\x8c0\x00\x00\x01\xc1\x80\x18\xfe89\xce01\x83\x01\x98`\x00\x00\x01d\x80\x0f\x800\x18\xcc03\x01\x81\xb0\xc0\xff\x80\x016\x80\x0e\x00p\x00x03\x01\x81a\xc1\xe1\x82\x03X\x80\x06\x00p\x00x?\xe3\x01\x83\xc3\x83!\x06\x02l\x00\x07\x00p\xf80?\xc3\x01\x83\xce\x87#\x0e\x06w\x80\x1e\x80p\xf800\xc3\x01\x87\xf8\x86"\x1c\x0c1\xc0x\xc0p\x1800\xe3\x01\x87\x81\x86b4\x188p\xe0@8800q\x83\x0c\x81\x0c\xc3\xe4p\x18>\x00@<x008\xfe\x1c\x81\xbf\x81\x86\xc0\x0c\x07\x90\xc0\x1f\xf000\x18|<\x80\xe2\x00\x03\x80\x0c0\xff\x80\x07\xc0\x00\x00\x00\x00h\x80\x00\x00\x00\x00\x060\x04\x00\x00\x00\x00\x00\x00\x00\x08\x80\x00\x00\x00\x00\x06\x98\x10\x00\x00\x00\x00\x00\x00\x00\x19\x80\x00\x00\x00\x00\x03\x8c\x10\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00\x01\x060\x00\x00\x00\x00\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x03`\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x01\xc0\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00')
gyroflow_fb = framebuf.FrameBuffer(gyroflow_bytearray, 128,28, framebuf.MONO_HLSB)
screen.blit(gyroflow_fb, 0, 2)
icon_gyroflow = framebuf.FrameBuffer(gyroflow_bytearray, 128,28, framebuf.MONO_HLSB)
screen.blit(icon_gyroflow, 0, 2+(16 if target.oled_height == 64 else 0))
screen.show_all()

def update_files():
Expand Down
42 changes: 0 additions & 42 deletions src/entry.py

This file was deleted.

1 change: 1 addition & 0 deletions src/gui/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

16 changes: 16 additions & 0 deletions src/gui/core/animation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Flowshutter
# Copyright (C) 2021 Hugo Chiang

# Flowshutter is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Flowshutter is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with flowshutter. If not, see <https://www.gnu.org/licenses/>.
# from framebuf import FrameBuffer as Buffer
Loading

0 comments on commit d70bf54

Please sign in to comment.