Skip to content

Commit

Permalink
Merge pull request #229 from Open-Smartwatch/develop
Browse files Browse the repository at this point in the history
New Release
  • Loading branch information
simonmicro authored May 31, 2022
2 parents 64e3f1d + 2256587 commit bc08af4
Show file tree
Hide file tree
Showing 192 changed files with 123,934 additions and 122,713 deletions.
120 changes: 70 additions & 50 deletions .github/buildEverything.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
import os
import shutil
import logging
import argparse
import subprocess
logging.basicConfig(level=logging.INFO)

# Configs
includeConfig = os.path.join('include', 'config.h')
pioConfig = 'platformio.ini'

# Configure editions
editions = [
'LIGHT_EDITION_V3_2',
'LIGHT_EDITION_V3_3',
'LIGHT_EDITION_V4_0',
'LIGHT_EDITION_DEV_LUA',
'GPS_EDITION_V3_1',
# GPS_EDITION_DEV_ROTATED not, as it is only for testing (right now)
]
editions = []
fh = open(pioConfig, 'r')
for line in fh.readlines():
if line.startswith('[env:'):
editions.append(line.strip()[5:-1])
fh.close()

# Find all languages
languages = []
langIncludePath = os.path.join('include', 'locales')
for fName in os.listdir(langIncludePath):
if os.path.join(os.path.join(langIncludePath, fName)):
languages.append(fName[:-2]) # This drops off the .h
languages.append(fName[:-2]) # This drops off the .h

# And compile!
for lang in languages:
def compile_model(lang, edition):
# Configs
includeConfig = os.path.join('include', 'config.h')

# Modify configs language
logging.info('Setting language to ' + lang + '...')
configIn = open(includeConfig, 'r')
Expand All @@ -45,44 +45,64 @@
# Always clean after changing the language (just-in-case)
logging.info('Cleanup...')
subprocess.run(['pio', 'run', '-t', 'clean'], capture_output=True)
for edition in editions:
filename = edition + '-' + lang + '.bin'
try:
os.remove(os.path.join('.', filename))
logging.info('Deleted ' + filename)
except OSError:
pass

filename = edition + '-' + lang + '.bin'
try:
os.remove(os.path.join('.', filename))
logging.info('Deleted ' + filename)
except OSError:
pass

# Compile editions
for edition in editions:
def doBuild(makeDebug):
# Setup variables
filename = edition + '-' + lang + ('-debug' if makeDebug else '') + '.bin'

# Setup build type (using the config file via replacing, as platformio does not allow setting the property using Python)
configIn = open(pioConfig, 'r')
configStr = configIn.read()
configIn.close()
configStr, hitCount = re.subn('(build_type\s?=\s?)(\w+)', r'\1' + ('debug' if makeDebug else 'release'), configStr)
if hitCount == 0:
logging.error('Error on setting build type!')
exit(4)
configOut = open(pioConfig, 'w')
configOut.write(configStr)
configOut.close()
def doBuild(makeDebug):
# Setup variables
filename = edition + '-' + lang + ('-debug' if makeDebug else '') + '.bin'

# Setup build type (using the config file via replacing, as platformio does not allow setting the property using Python)
configIn = open(pioConfig, 'r')
configStr = configIn.read()
configIn.close()
configStr, hitCount = re.subn('(build_type\s?=\s?)(\w+)', r'\1' + ('debug' if makeDebug else 'release'), configStr)
if hitCount == 0:
logging.error('Error on setting build type!')
exit(4)
configOut = open(pioConfig, 'w')
configOut.write(configStr)
configOut.close()

# Compile firmware
logging.info('Compiling ' + filename + '...')
try:
res = subprocess.run(['pio', 'run', '-e', edition], capture_output=True)
except KeyboardInterrupt:
exit(3)
if res.returncode != 0:
logging.error('COMPILATION FAILED')
logging.error(res.stderr.decode())
exit(2)
# "Export" firmware.bin
shutil.copy(os.path.join('.pio', 'build', edition, 'firmware.bin'), os.path.join('.', filename))
doBuild(True)
doBuild(False)

if __name__ == "__main__":

ap = argparse.ArgumentParser()

ap.add_argument("-l", "--support-language", type=str, required=True, help="# model language to compile. (Enter 'all' to compile all language packs.)")
ap.add_argument("-m", "--support-model", type=str, required=True, help="# model type to compile. (Enter 'all' to compile all model packs.)")
args = vars(ap.parse_args())

# Compile firmware
logging.info('Compiling ' + filename + '...')
try:
res = subprocess.run(['pio', 'run', '-e', edition], capture_output=True)
except KeyboardInterrupt:
exit(3)
if res.returncode != 0:
logging.error('COMPILATION FAILED')
logging.error(res.stderr.decode())
exit(2)

# "Export" firmware.bin
shutil.copy(os.path.join('.pio', 'build', edition, 'firmware.bin'), os.path.join('.', filename))
doBuild(True)
doBuild(False)
#if you want all-language packs
if args["support_language"] == "all" and args["support_model"] == "all":
for lang in languages:
for edition in editions:
compile_model(lang,edition)
elif args["support_language"] == "all" and args["support_model"] != "all":
for lang in languages:
compile_model(lang, args["support_model"])
elif args["support_language"] != "all" and args["support_model"] == "all":
for edition in editions:
compile_model(args["support_language"], edition)
else :
compile_model(args["support_language"], args["support_model"])
44 changes: 0 additions & 44 deletions .github/workflows/actions.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/astyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# https://peterevans.dev/posts/github-actions-how-to-automate-code-formatting-in-pull-requests/

name: auto-format
on:
# pull_request would be OK, but will ignore direct pushes to the master (which can't be protected on private repos) - therefore just run it always (force-push as you wish on your private branches)
push:
branches:
- 'master'
- 'develop'
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
ref: ${{ github.head_ref }}
- name: astyle
uses: addnab/docker-run-action@v3
with:
image: weberlars/astyle:latest
options: -v ${{ github.workspace }}:/workspace
run: astyle --style=google --recursive /workspace/*.c,*.cc,*.cpp,*.h,*.hpp --suffix=none --indent=spaces --align-pointer=type --align-reference=type --convert-tabs --preserve-date --lineend=linux
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Push changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.email '[email protected]'
git config --global user.name 'GitHub Action'
git commit -am 'Applied formatting'
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
64 changes: 64 additions & 0 deletions .github/workflows/test-OSW.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: OSW-OS-test

on:
workflow_dispatch:
push:
pull_request:
branches: [ master, develop ]

jobs:
Find-packages:
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive
- id: get-languages
run: echo "::set-output name=languages_matrix::$(cd include/locales/; X=$(ls *.h -1 | sed -e 's/\.h$//' | tr '\n' ' '); X=($X); jq --compact-output --null-input '$ARGS.positional' --args -- "${X[@]}")"
- id: get-models
run: echo "::set-output name=models_matrix::$(F=$(cat platformio.ini | grep "\[\env:" | sed -e 's/\[\env://' | tr ']\n' ' ');F=($F);jq --compact-output --null-input '$ARGS.positional' --args -- "${F[@]}")"
outputs:
languages_matrix: ${{ steps.get-languages.outputs.languages_matrix }}
models_matrix: ${{ steps.get-models.outputs.models_matrix }}
build-OSW:
needs: Find-packages
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ${{ fromJson(needs.Find-packages.outputs.languages_matrix) }}
model: ${{ fromJson(needs.Find-packages.outputs.models_matrix) }}
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: cache-${{ secrets.CACHE_VERSION }}-${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: cache-${{ secrets.CACHE_VERSION }}-${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Install swig
run: sudo apt-get update && sudo apt-get -y install swig
- name: Set up Python
uses: actions/setup-python@v2
- name: Install PlatformIO
run: python -m pip install --upgrade pip && pip install --upgrade platformio
- name: Rename config
run: mv include/config.h.example include/config.h
- name: Compile language ${{ matrix.language }} model ${{ matrix.model }}
run: python3 .github/buildEverything.py -l ${{ matrix.language }} -m ${{ matrix.model }}
- name: Upload firmware artifacts
uses: actions/upload-artifact@v2
with:
name: firmwares
path: |
*.bin
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The raw screenserver runs in the background and prints via serial:

```
Started Raw ScreenServer
http://<IP_OF_WATCH>:8080/screen.raw
http://<IP_OF_WATCH>/api/screenserver
```

### HowTo
Expand Down
2 changes: 1 addition & 1 deletion composeScreen.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if [ -z "$1" ] || [ -z "$2" ];
then
echo "usage: fetchScreen.sh <INPUT-IMAGE> <OUTPUT-IMAGE>"
echo "usage: composeScreen.sh <INPUT-IMAGE> <OUTPUT-IMAGE>"
exit
fi

Expand Down
2 changes: 1 addition & 1 deletion createScreenshot.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if [ -z "$1" ] || [ -z "$2" ];
then
echo "usage: fetchScreen.sh <IP> <FILE-BASE-NAME>"
echo "usage: createScreenshot.sh <IP> <FILE-BASE-NAME>"
exit
fi

Expand Down
2 changes: 1 addition & 1 deletion fetchScreen.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi

TEMPFILE=temp.raw

curl http://$1:8080/screen.raw --output $TEMPFILE
curl http://$1/api/screenserver --output $TEMPFILE
convert -size 240x240 -depth 8 rgb:$TEMPFILE $2

if [ -f $TEMPFILE ];
Expand Down
26 changes: 13 additions & 13 deletions include/Arduino_Canvas_Graphics2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
#include <gfx_2d_print.h>

class Arduino_Canvas_Graphics2D : public Arduino_GFX {
public:
Arduino_Canvas_Graphics2D(int16_t w, int16_t h, Arduino_G *output, int16_t output_x = 0, int16_t output_y = 0);
public:
Arduino_Canvas_Graphics2D(int16_t w, int16_t h, Arduino_G* output, int16_t output_x = 0, int16_t output_y = 0);

void begin(int32_t speed = 0);
void writePixelPreclipped(int16_t x, int16_t y, uint16_t color);
void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
void flush(void);
void begin(int32_t speed = 0);
void writePixelPreclipped(int16_t x, int16_t y, uint16_t color);
void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
void flush(void);

Graphics2DPrint *getGraphics2D(void);
Graphics2DPrint* getGraphics2D(void);

protected:
Graphics2DPrint *_gfx2d;
Arduino_G *_output;
int16_t _output_x, _output_y;
protected:
Graphics2DPrint* _gfx2d;
Arduino_G* _output;
int16_t _output_x, _output_y;

private:
private:
};

#endif
12 changes: 6 additions & 6 deletions include/apps/_experiments/autumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#include "osw_app.h"

class OswAppAutumn : public OswApp {
public:
OswAppAutumn(){};
virtual void setup() override;
virtual void loop() override;
~OswAppAutumn(){};
public:
OswAppAutumn() {};
virtual void setup() override;
virtual void loop() override;
~OswAppAutumn() {};

private:
private:
};

#endif
Loading

0 comments on commit bc08af4

Please sign in to comment.