-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from lovyan03/develop
0.2.6
- Loading branch information
Showing
18 changed files
with
1,045 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
on: | ||
release: | ||
types: | ||
- published | ||
workflow_dispatch: | ||
inputs: | ||
versiontype: | ||
description: 'Version upgrade type (p)atch/(m)inor/(M)ajor/(F)orced' | ||
required: true | ||
default: 'p' | ||
versionforced: | ||
description: 'Optional (F)orced version, leave blank for auto-raise' | ||
required: false | ||
default: '' | ||
jobs: | ||
on_release_semver_next: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: master # this must match the main/master branch name !! | ||
- name: Semver-Iterator | ||
run: | | ||
chmod +x $GITHUB_WORKSPACE/.github/scripts/semver.sh | ||
echo "Running $GITHUB_WORKSPACE/.github/scripts/semver.sh -${{ github.event.inputs.versiontype }} ${{ github.event.inputs.versionforced }} " | ||
$GITHUB_WORKSPACE/.github/scripts/semver.sh -${{ github.event.inputs.versiontype }} ${{ github.event.inputs.versionforced }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
commit-message: "raising version" | ||
title: "Semver-Iterator auto-raise" | ||
body: | | ||
A version change occured |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
#!/bin/bash | ||
|
||
|
||
function patchpropertyfiles { | ||
|
||
old_tag=$1 | ||
new_tag=$2 | ||
|
||
echo "Patching property/json/tag files $old_tag => $new_tag" | ||
|
||
if [ -f "$GITHUB_WORKSPACE/library.json" ]; then | ||
sed -i -e "s/\"$old_tag\"/\"$new_tag\"/g" $GITHUB_WORKSPACE/library.json | ||
cat $GITHUB_WORKSPACE/library.json | ||
fi | ||
|
||
if [ -f "$GITHUB_WORKSPACE/library.properties" ]; then | ||
sed -i -e "s/version=$old_tag/version=$new_tag/g" $GITHUB_WORKSPACE/library.properties | ||
cat $GITHUB_WORKSPACE/library.properties | ||
fi | ||
|
||
if [ -f "$GITHUB_WORKSPACE/src/gitTagVersion.h" ]; then | ||
sed -i -e "s/\"$old_tag\"/\"$new_tag\"/g" $GITHUB_WORKSPACE/src/gitTagVersion.h | ||
cat $GITHUB_WORKSPACE/src/gitTagVersion.h | ||
fi | ||
|
||
} | ||
|
||
|
||
|
||
if [ $GITHUB_EVENT_NAME == "workflow_dispatch" ]; then | ||
|
||
echo "Workflow dispatched event, guessing version from properties file" | ||
localtag=`cat $GITHUB_WORKSPACE/library.properties | grep version` | ||
RELEASE_TAG=${localtag//version=/ } | ||
minor=true | ||
|
||
else | ||
|
||
if [ ! $GITHUB_EVENT_NAME == "release" ]; then | ||
echo "Wrong event '$GITHUB_EVENT_NAME'!" | ||
exit 1 | ||
fi | ||
|
||
EVENT_JSON=`cat $GITHUB_EVENT_PATH` | ||
|
||
action=`echo $EVENT_JSON | jq -r '.action'` | ||
if [ ! $action == "published" ]; then | ||
echo "Wrong action '$action'. Exiting now..." | ||
exit 0 | ||
fi | ||
|
||
draft=`echo $EVENT_JSON | jq -r '.release.draft'` | ||
if [ $draft == "true" ]; then | ||
echo "It's a draft release. Exiting now..." | ||
exit 0 | ||
fi | ||
|
||
RELEASE_PRE=`echo $EVENT_JSON | jq -r '.release.prerelease'` | ||
RELEASE_TAG=`echo $EVENT_JSON | jq -r '.release.tag_name'` | ||
RELEASE_BRANCH=`echo $EVENT_JSON | jq -r '.release.target_commitish'` | ||
RELEASE_ID=`echo $EVENT_JSON | jq -r '.release.id'` | ||
RELEASE_BODY=`echo $EVENT_JSON | jq -r '.release.body'` | ||
|
||
echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPACE, Ref: $GITHUB_REF" | ||
echo "Action: $action, Branch: $RELEASE_BRANCH, ID: $RELEASE_ID" | ||
echo "Tag: $RELEASE_TAG, Draft: $draft, Pre-Release: $RELEASE_PRE" | ||
|
||
fi | ||
|
||
|
||
# Increment a version string using Semantic Versioning (SemVer) terminology. | ||
major=false; | ||
minor=false; | ||
patch=false; | ||
|
||
while getopts ":MmpF:" Option | ||
do | ||
case $Option in | ||
M ) major=true;; | ||
m ) minor=true;; | ||
p ) patch=true;; | ||
F ) | ||
version=${OPTARG} | ||
if [ "$version" == "auto" ]; then | ||
# default to patch | ||
patch=true | ||
else | ||
forcedversion=true | ||
echo "Forcing version to $version" | ||
fi | ||
;; | ||
* ) echo "NOTHING TO DO";; | ||
esac | ||
done | ||
|
||
if [ $OPTIND -eq 1 ]; then | ||
echo "No options were passed, assuming patch level" | ||
patch=true | ||
fi | ||
|
||
|
||
if [ -z ${RELEASE_TAG} ] | ||
then | ||
echo "Couldn't determine version" | ||
exit 1 | ||
fi | ||
|
||
|
||
if [ "$forcedversion" != "true" ]; then | ||
|
||
# Build array from version string. | ||
|
||
a=( ${RELEASE_TAG//./ } ) | ||
major_version=0 | ||
# If version string is missing or has the wrong number of members, show usage message. | ||
|
||
if [ ${#a[@]} -ne 3 ]; then | ||
echo "usage: $(basename $0) [-Mmp] major.minor.patch" | ||
exit 1 | ||
fi | ||
|
||
# Increment version numbers as requested. | ||
|
||
if [ $major == "true" ]; then | ||
echo "Raising MAJOR" | ||
# Check for v in version (e.g. v1.0 not just 1.0) | ||
if [[ ${a[0]} =~ ([vV]?)([0-9]+) ]]; then | ||
v="${BASH_REMATCH[1]}" | ||
major_version=${BASH_REMATCH[2]} | ||
((major_version++)) | ||
a[0]=${v}${major_version} | ||
else | ||
((a[0]++)) | ||
major_version=a[0] | ||
fi | ||
|
||
a[1]=0 | ||
a[2]=0 | ||
fi | ||
|
||
if [ $minor == "true" ]; then | ||
echo "Raising MINOR" | ||
((a[1]++)) | ||
a[2]=0 | ||
fi | ||
|
||
if [ $patch == "true" ]; then | ||
echo "Raising PATCH" | ||
((a[2]++)) | ||
fi | ||
|
||
version=$(echo "${a[0]}.${a[1]}.${a[2]}") | ||
|
||
fi | ||
|
||
patchpropertyfiles $RELEASE_TAG $version | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
#include <LovyanGFX.hpp> | ||
|
||
static LGFX lcd; | ||
static LGFX_Sprite sp; | ||
static LGFX_Sprite sprites[2]; | ||
static bool flip; | ||
static int sprite_height; | ||
|
||
inline uint16_t getBackColor(int x, int y) | ||
{ | ||
return lcd.swap565(abs((x&31)-16)<<3, 0, abs((y&31)-16)<<3); | ||
//return lcd.swap565(x, 0, y); | ||
} | ||
|
||
void setup(void) | ||
{ | ||
lcd.init(); | ||
|
||
if (lcd.width() < lcd.height()) { lcd.setRotation(lcd.getRotation()^1); } | ||
|
||
for (int i = 0; i < 2; i++) | ||
{ | ||
sprites[i].setColorDepth(lcd.getColorDepth()); | ||
sprites[i].setFont(&fonts::Font2); | ||
sprites[i].setTextColor(TFT_WHITE); | ||
sprites[i].setTextDatum(textdatum_t::top_right); | ||
} | ||
|
||
int div = 1; | ||
for (;;) | ||
{ | ||
sprite_height = (lcd.height() + div - 1) / div; | ||
bool fail = false; | ||
for (int i = 0; !fail && i < 2; ++i) | ||
{ | ||
fail = !sprites[i].createSprite(lcd.width(), sprite_height); | ||
} | ||
if (!fail) break; | ||
for (int i = 0; i < 2; ++i) | ||
{ | ||
sprites[i].deleteSprite(); | ||
} | ||
div++; | ||
} | ||
|
||
sp.setColorDepth(8); | ||
sp.setFont(&fonts::Font2); | ||
sp.setTextDatum(textdatum_t::middle_center); | ||
|
||
lcd.startWrite(); | ||
} | ||
|
||
void loop(void) | ||
{ | ||
static int count; | ||
static int prev_sec; | ||
static int prev_fps; | ||
static int fps; | ||
++fps; | ||
int sec = millis() / 1000; | ||
if (prev_sec != sec) | ||
{ | ||
prev_sec = sec; | ||
prev_fps = fps; | ||
fps = 0; | ||
} | ||
count++; | ||
|
||
float y_center = (std::max(lcd.width(), lcd.height())); | ||
float distance; | ||
float zoom_x, zoom_y; | ||
|
||
for (int div_y = 0; div_y < lcd.height(); div_y += sprite_height) | ||
{ | ||
float angle = (float)(count * 36) / 100; | ||
// sprites[flip].clear(); | ||
//* // draw background | ||
std::uint16_t* rawbuf = (std::uint16_t*)sprites[flip].getBuffer(); | ||
for (int y = 0; y < sprite_height; y++) | ||
{ | ||
std::uint16_t* rawline = &rawbuf[y * lcd.width()]; | ||
for (int x = 0; x < lcd.width(); x++) | ||
{ | ||
rawline[x] = getBackColor(x, div_y + y); | ||
} | ||
} | ||
//*/ | ||
|
||
sp.setTextColor(TFT_WHITE, TFT_BLACK); | ||
if (div_y == 0) | ||
{ | ||
// draw fps and counter | ||
sprites[flip].setCursor(0,0); | ||
sprites[flip].printf("fps:%03d", prev_fps); | ||
sprites[flip].drawNumber(count, lcd.width(), 0); | ||
|
||
distance = y_center; | ||
zoom_x = distance / 512.0f; | ||
zoom_y = distance / 256.0f; | ||
sp.createSprite(21, 11); | ||
sp.fillTriangle(0, 0, 20, 0, 10, 10, TFT_WHITE); | ||
sp.setPivot(10, distance / zoom_y - 0.5); | ||
sp.pushRotateZoomWithAA(&sprites[flip], lcd.width() / 2, y_center - div_y, 0, zoom_x, zoom_y, 0); | ||
} | ||
|
||
|
||
// draw outer dial | ||
distance = y_center * 0.95; | ||
zoom_y = distance / 30; | ||
sp.createSprite(1, 1); | ||
sp.clear(TFT_WHITE); | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
float a = fmodf(360.0f + angle - i * 3.6f, 360.0f); | ||
if (a > 40 && a < 320) continue; | ||
|
||
zoom_x = distance / (i%5 ? 50 : 30); | ||
zoom_y = distance / (i%5 ? 30 : ((i % 10) ? 20 : 15)); | ||
sp.setPivot(0, distance / zoom_y - 0.5); | ||
sp.pushRotateZoomWithAA(&sprites[flip], lcd.width() / 2, y_center - div_y, a, zoom_x, zoom_y, 0); | ||
} | ||
|
||
// draw outer number | ||
distance *= 0.92; | ||
zoom_x = distance / 128.0f; | ||
zoom_y = distance / 128.0f; | ||
sp.createSprite(18, 14); | ||
sp.setPivot((float)sp.width() / 2, distance / zoom_y); | ||
for (int i = 0; i < 100; i += 10) | ||
{ | ||
float a = fmodf(360.0f + angle - i * 3.6f, 360.0f); | ||
if (a > 50 && a < 310) continue; | ||
sp.drawNumber(i, sp.width()>>1, sp.height()>>1); | ||
sp.pushRotateZoomWithAA(&sprites[flip], lcd.width() / 2, y_center - div_y, a, zoom_x, zoom_y, 0); | ||
} | ||
|
||
|
||
// draw inner dial | ||
angle /= 10; | ||
distance *= 0.85; | ||
sp.createSprite(1, 1); | ||
sp.setTextColor(TFT_YELLOW, TFT_BLACK); | ||
sp.clear(TFT_YELLOW); | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
float a = fmodf(360.0f + angle - i * 3.6f, 360.0f); | ||
if (a > 60 && a < 300) continue; | ||
|
||
zoom_x = distance / (i%5 ? 50 : 30); | ||
zoom_y = distance / (i%5 ? 30 : ((i % 10) ? 20 : 15)); | ||
sp.setPivot(0, distance / zoom_y - 0.5); | ||
sp.pushRotateZoomWithAA(&sprites[flip], lcd.width() / 2, y_center - div_y, a, zoom_x, zoom_y, 0); | ||
} | ||
|
||
// draw inner number | ||
distance *= 0.9; | ||
zoom_x = distance / 128.0f; | ||
zoom_y = distance / 128.0f; | ||
sp.createSprite(21, 14); | ||
sp.setPivot((float)sp.width() / 2, distance / zoom_y); | ||
for (int i = 0; i < 100; i += 10) | ||
{ | ||
float a = fmodf(360.0f + angle - i * 3.6f, 360.0f); | ||
if (a > 70 && a < 290) continue; | ||
sp.drawFloat(float(i)/100, 1, sp.width()>>1, sp.height()>>1); | ||
sp.pushRotateZoomWithAA(&sprites[flip], lcd.width() / 2, y_center - div_y, a, zoom_x, zoom_y, 0); | ||
} | ||
|
||
sprites[flip].pushSprite(&lcd, 0, div_y); | ||
flip = !flip; | ||
} | ||
} |
Oops, something went wrong.