-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
943 additions
and
682 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 @@ | ||
github: awawa-dev |
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,88 @@ | ||
name: HyperSerialEsp8266 CI Build | ||
|
||
on: [push] | ||
|
||
jobs: | ||
|
||
###################### | ||
#### PlatformIO ###### | ||
###################### | ||
|
||
PlatformIO: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cache pip | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Cache PlatformIO | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.platformio | ||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.x | ||
- name: Install PlatformIO | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade platformio | ||
- name: Run PlatformIO | ||
run: pio run | ||
- uses: actions/upload-artifact@v3 | ||
name: Upload artifacts (commit) | ||
if: (startsWith(github.event.ref, 'refs/tags') != true) | ||
with: | ||
path: | | ||
.pio/build/*.bin | ||
- uses: actions/upload-artifact@v3 | ||
name: Upload artifacts (release) | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
name: firmware-release | ||
path: | | ||
.pio/build/*.bin | ||
################################ | ||
###### Publish Releases ######## | ||
################################ | ||
|
||
publish: | ||
name: Publish Releases | ||
if: startsWith(github.event.ref, 'refs/tags') | ||
needs: [PlatformIO] | ||
runs-on: ubuntu-latest | ||
steps: | ||
# generate environment variables | ||
- name: Generate environment variables from version and tag | ||
run: | | ||
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | ||
echo "preRelease=false" >> $GITHUB_ENV | ||
# If version contains alpha or beta, mark draft release as pre-release | ||
- name: Mark release as pre-release | ||
if: contains(env.VERSION, 'alpha') || contains(env.VERSION, 'beta') | ||
run: echo "preRelease=true" >> $GITHUB_ENV | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: firmware-release | ||
|
||
# create draft release and upload artifacts | ||
- name: Create draft release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: HyperSerialEsp8266 ${{ env.VERSION }} | ||
tag_name: ${{ env.TAG }} | ||
files: | | ||
*.bin | ||
draft: true | ||
prerelease: ${{ env.preRelease }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,5 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch |
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,10 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"platformio.platformio-ide" | ||
], | ||
"unwantedRecommendations": [ | ||
"ms-vscode.cpptools-extension-pack" | ||
] | ||
} |
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,13 @@ | ||
Import("env") | ||
from pathlib import Path | ||
import shutil | ||
|
||
|
||
def post_program_action(source, target, env): | ||
program_path = target[0].get_abspath() | ||
path = Path(program_path) | ||
shutil.copy(program_path, path.parent.parent.absolute()) | ||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", post_program_action) | ||
|
||
env.Replace(PROGNAME="firmware_%s" % env.GetProjectOption("custom_prog_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
This directory is intended for project header files. | ||
|
||
A header file is a file containing C declarations and macro definitions | ||
to be shared between several project source files. You request the use of a | ||
header file in your project source file (C, C++, etc) located in `src` folder | ||
by including it, with the C preprocessing directive `#include'. | ||
|
||
```src/main.c | ||
|
||
#include "header.h" | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
``` | ||
|
||
Including a header file produces the same results as copying the header file | ||
into each source file that needs it. Such copying would be time-consuming | ||
and error-prone. With a header file, the related declarations appear | ||
in only one place. If they need to be changed, they can be changed in one | ||
place, and programs that include the header file will automatically use the | ||
new version when next recompiled. The header file eliminates the labor of | ||
finding and changing all the copies as well as the risk that a failure to | ||
find one copy will result in inconsistencies within a program. | ||
|
||
In C, the usual convention is to give header files names that end with `.h'. | ||
It is most portable to use only letters, digits, dashes, and underscores in | ||
header file names, and at most one dot. | ||
|
||
Read more about using header files in official GCC documentation: | ||
|
||
* Include Syntax | ||
* Include Operation | ||
* Once-Only Headers | ||
* Computed Includes | ||
|
||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html |
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,82 @@ | ||
/* calibration.h | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2022 awawa-dev | ||
* | ||
* https://github.com/awawa-dev/HyperSerialEsp8266 | ||
* | ||
* 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. | ||
*/ | ||
|
||
#ifndef CALIBRATION_H | ||
#define CALIBRATION_H | ||
|
||
#include <stdint.h> | ||
#include <algorithm> | ||
|
||
#define ROUND_DIVIDE(numer, denom) (((numer) + (denom) / 2) / (denom)) | ||
|
||
struct { | ||
uint8_t white[256]; | ||
uint8_t red[256]; | ||
uint8_t green[256]; | ||
uint8_t blue[256]; | ||
} channelCorrection; | ||
|
||
struct { | ||
uint8_t gain = 0xFF; | ||
#ifdef COLD_WHITE | ||
uint8_t red = 0xA0; // adjust red -> white in 0-0xFF range | ||
uint8_t green = 0xA0; // adjust green -> white in 0-0xFF range | ||
uint8_t blue = 0xA0; // adjust blue -> white in 0-0xFF range | ||
#else | ||
uint8_t red = 0xB0; // adjust red -> white in 0-0xFF range | ||
uint8_t green = 0xB0; // adjust green -> white in 0-0xFF range | ||
uint8_t blue = 0x70; // adjust blue -> white in 0-0xFF range | ||
#endif | ||
|
||
void setParams(uint8_t _gain, uint8_t _red, uint8_t _green, uint8_t _blue) | ||
{ | ||
gain = _gain; | ||
red = _red; | ||
green = _green; | ||
blue = _blue; | ||
} | ||
|
||
void prepareCalibration() | ||
{ | ||
// prepare LUT calibration table, cold white is much better than "neutral" white | ||
for (uint32_t i = 0; i < 256; i++) | ||
{ | ||
// color calibration | ||
uint32_t _gain = uint32_t(gain) * i; // adjust gain | ||
uint32_t _red = red * i; // adjust red | ||
uint32_t _green = green * i; // adjust green | ||
uint32_t _blue = blue * i; // adjust blue | ||
|
||
channelCorrection.white[i] = (uint8_t)std::min(ROUND_DIVIDE(_gain, 0xFF), (uint32_t)0xFF); | ||
channelCorrection.red[i] = (uint8_t)std::min(ROUND_DIVIDE(_red, 0xFF), (uint32_t)0xFF); | ||
channelCorrection.green[i] = (uint8_t)std::min(ROUND_DIVIDE(_green,0xFF), (uint32_t)0xFF); | ||
channelCorrection.blue[i] = (uint8_t)std::min(ROUND_DIVIDE(_blue, 0xFF), (uint32_t)0xFF); | ||
} | ||
} | ||
} calibrationConfig; | ||
#endif | ||
|
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,46 @@ | ||
|
||
This directory is intended for project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link into executable file. | ||
|
||
The source code of each library should be placed in a an own separate directory | ||
("lib/your_library_name/[here are source files]"). | ||
|
||
For example, see a structure of the following two libraries `Foo` and `Bar`: | ||
|
||
|--lib | ||
| | | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html | ||
| | | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| | | ||
| |- README --> THIS FILE | ||
| | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
and a contents of `src/main.c`: | ||
``` | ||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
|
||
``` | ||
|
||
PlatformIO Library Dependency Finder will find automatically dependent | ||
libraries scanning project source files. | ||
|
||
More information about PlatformIO Library Dependency Finder | ||
- https://docs.platformio.org/page/librarymanager/ldf.html |
Oops, something went wrong.