Skip to content

Commit

Permalink
Merge pull request #60 from lovyan03/develop
Browse files Browse the repository at this point in the history
0.2.6
  • Loading branch information
lovyan03 authored Nov 9, 2020
2 parents b1e9255 + de96ed2 commit a4183b7
Show file tree
Hide file tree
Showing 18 changed files with 1,045 additions and 414 deletions.
35 changes: 35 additions & 0 deletions .github/Workflows/onrelease.yml
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
157 changes: 157 additions & 0 deletions .github/scripts/semver.sh
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

6 changes: 3 additions & 3 deletions examples/HowToUse/5_images/5_images.ino
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ setAddrWindow は描画範囲外が指定された場合は範囲内に調整さ
lcd.pushImage( 0, 0, image_width, image_height, (uint16_t*)rgb565); // RGB565の16bit画像データを描画。

// データとバイト順変換の指定が一致していない場合、色化けします。
lcd.pushImage( 0, 40, image_width, image_height, (uint16_t*)swap565); // ビッグエンディアンの16bit画像データは色が化ける
lcd.pushImage( 0, 40, image_width, image_height, (uint16_t*)swap565); // NG. バイト順変換済みデータにバイト順変換を行うと色化けする

// 描画範囲が画面外にはみ出すなどした場合でも、描画結果が崩れることはありません。
lcd.pushImage(-1, 80, image_width, image_height, (uint16_t*)rgb565); // X座標-1(画面外)を指定しても描画は乱れない。
Expand Down Expand Up @@ -160,8 +160,8 @@ setAddrWindow は描画範囲外が指定された場合は範囲内に調整さ
lcd.pushImage(120, 0, image_width, image_height, (lgfx:: rgb332_t*) rgb332); // good 8bitデータ
lcd.pushImage(120, 40, image_width, image_height, (lgfx:: rgb565_t*) rgb565); // good 16bitデータ
lcd.pushImage(120, 80, image_width, image_height, (lgfx:: rgb888_t*) rgb888); // good 24bitデータ
lcd.pushImage(120, 120, image_width, image_height, (lgfx::swap565_t*)swap565); // good スワップ済み16bitデータ
lcd.pushImage(120, 160, image_width, image_height, (lgfx:: bgr888_t*) bgr888); // good スワップ済み24bitデータ
lcd.pushImage(120, 120, image_width, image_height, (lgfx::swap565_t*)swap565); // good バイト順変換済み16bitデータ
lcd.pushImage(120, 160, image_width, image_height, (lgfx:: bgr888_t*) bgr888); // good バイト順変換済み24bitデータ

// 第6引数で透過色を指定できます。透過指定された色のある部分は描画されません。
lcd.pushImage(160, 0, image_width, image_height, (lgfx:: rgb332_t*) rgb332, 0); // 黒を透過指定
Expand Down
172 changes: 172 additions & 0 deletions examples/Sprite/RotateDial/RotateDial.ino
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;
}
}
Loading

0 comments on commit a4183b7

Please sign in to comment.