-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 6f5e093
Showing
21 changed files
with
1,330 additions
and
0 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 @@ | ||
-name *.lua ! -name debug*.* |
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,9 @@ | ||
/bin/* | ||
!/bin/build.sh | ||
/node_modules | ||
/obj | ||
/releases | ||
.builderr | ||
*.lnk | ||
batchk.lua | ||
debug.lua |
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 @@ | ||
-name *.lua ! -wholename src/SCRIPTS/GRAPHS/graphs.lua |
Large diffs are not rendered by default.
Oops, something went wrong.
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,2 @@ | ||
all: | ||
bin/build.sh min |
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,112 @@ | ||
# opentx-lua-running-graphs | ||
|
||
**Draws a moving line graph from a given source.** | ||
|
||
Example screens on X7 display with single/multiple graphs ... | ||
|
||
![alt text](img/graph.lua.gif "TELEMETRY/graph.lua") | ||
![alt text](img/graphs.lua.gif "TELEMETRY/graphs.lua") | ||
|
||
... and inside a widget grid*. | ||
|
||
![alt text](../opentx-lua-widgets/img/wdgts2.lua.gif "TELEMETRY/wdgts2.lua") | ||
|
||
> \**part of the [opentx-lua-widgets](https://github.com/Matze-Jung/opentx-lua-widgets) package* | ||
## Test environment | ||
* OpenTX v2.2.4 on Taranis Q X7, Betaflight 4.0.5 on OmnibusF4 w/ R-XSR | ||
* Companion Sim v2.2.4 (*FrSky platforms only*) | ||
|
||
## Download | ||
Please go to the [releases page](https://github.com/Matze-Jung/opentx-lua-running-graphs/releases) to download the latest files. | ||
|
||
## Installing | ||
Unzip the files from the release package and drag the contents to your radio. If you do this correctly, the `SCRIPTS` directory will merge with your existing directories, placing the scripts in their appropriate paths. | ||
|
||
The `src` directory is not required for use and is only available for maintenance of the code. While it may work to use this directory, you may encounter memory issues on your transmitter. | ||
|
||
How to copy to the Transmitter: | ||
|
||
**A**) Bootloader Method | ||
1. Power off your transmitter and power it back on in boot loader mode. | ||
2. Connect a USB cable and open the SD card drive on your computer. | ||
3. Unzip the file and copy the scripts to the root of the SD card. | ||
4. Unplug the USB cable and power cycle your transmitter. | ||
|
||
**B**) Manual method (varies, based on the model of your transmitter) | ||
1. Power off your transmitter. | ||
2. Remove the SD card and plug it into a computer | ||
3. Unzip the file and copy the scripts to the root of the SD card. | ||
4. Reinsert your SD card into the transmitter | ||
5. Power up your transmitter. | ||
|
||
If you copied the files correctly, you can now go to the `CUSTOM SCRIPTS` screen and select the script `graphs`: | ||
1. Hit the [MENU] button | ||
2. Long-press [PAGE] and repeat til page `CUSTOM SCRIPTS` | ||
3. Select a free slot and [ENT] | ||
4. Select the script `graphs` and [ENT] | ||
5. Press [EXIT] to return. | ||
|
||
![alt text](img/CUSTOMSCRIPTS.gif "CUSTOM SCRIPTS") | ||
|
||
Go to the telemetry screen setup page and select telemetry pages. | ||
|
||
## Setup | ||
Setting up the script as a telemetry page will enable access at the press of a button (on X7/X9 platforms). | ||
1. Hit the [MENU] button and select the model for which you would like to enable the script. | ||
2. While on the `MODEL SELECTION` screen, long-press the [PAGE] button to navigate to the `DISPLAY` page. | ||
3. Move the cursor down to `Screen 1` and hit [ENT]. | ||
4. Select the `Script` option and press [ENT]. | ||
5. Move the cursor to the script selection field `---` and hit [ENT]. | ||
6. Select one of the example telemetry scripts and hit [ENT]. | ||
7. Long-press [EXIT] to return to your model screen. | ||
|
||
![alt text](img/DISPLAY.gif "DISPLAY") | ||
|
||
To invoke the script, simply long-press the [PAGE] button from the model screen. | ||
|
||
## API | ||
#### Functions | ||
`createGraph(id, opts)` | ||
|
||
Init and display the graph. | ||
|
||
| Option | Type | Description | | ||
| - | - | - | | ||
| **id** | number | Systemwide unique ID of the graph | | ||
| opts.**src** | function/string/number | Data source | | ||
| opts.**max** | number | Largest possible value | | ||
| opts.**min** | number | Smallest possible value | | ||
| opts.**speed** | number *(optional, default `75`)* | Update speed in 100ths second intervals, smaller is faster | | ||
| opts.**style** | number *(optional, default `SOLID` - `DOTTED` at 'min' and 'max' values)* | `SOLID` for a full solid line, `DOTTED` for a dotted line | | ||
| opts.**crit** | number *(optional)* | If set, the line style is `DOTTED` below and `SOLID` above this value. The X-axis gets a mark at the values position | | ||
|
||
--- | ||
`getGraphAverage(id)` | ||
|
||
Returns average value of graph, specified by `id`. | ||
|
||
| Option | Type | Description | | ||
| - | - | - | | ||
| **id** | number | ID of the graph | | ||
|
||
#### Trigger | ||
Set input condition for the pause toggle. Relates to all graphs global. | ||
|
||
`src/SCRIPTS/GRAPHS/trigger.lua` | ||
|
||
```lua | ||
return { | ||
pause = { | ||
func=function() | ||
return getValue("sa") > 100 | ||
end | ||
}, | ||
} | ||
``` | ||
|
||
## Building from source | ||
- Be sure to have `LUA 5.2`and `Node.js` installed | ||
- Run `npm install` from the root folder to install node modules | ||
- Run `npm start`, `make` or `./bin/build.sh min` from the root folder with appropriate privileges (omit the `min` switch to build without minifying) | ||
- Compiled/minified files will be created at the `obj` folder. Copy the files to your transmitter. |
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,105 @@ | ||
#!/bin/bash | ||
|
||
MINIFY=$1 | ||
ERRCNT=0 | ||
|
||
if [ -d obj ]; then | ||
rm -fR obj/* | ||
else | ||
mkdir obj | ||
fi | ||
|
||
if [ -d tmp ]; then | ||
rm -dfR tmp | ||
fi | ||
mkdir tmp | ||
|
||
echo | ||
luac -v | ||
|
||
if [[ $MINIFY == "min" ]]; then | ||
echo | ||
echo luamin $(npm view luamin version)" "Copyright Mathias Bynens [https://github.com/mathiasbynens/luamin] | ||
fi | ||
|
||
if [ -f .minignore ]; then | ||
EXCLUDE=(`find src/* $(<.minignore)`); | ||
fi | ||
|
||
MANIFEST=(`find src/* $(<.buildfiles)`); | ||
|
||
if [ ${#MANIFEST[@]} -eq 0 ]; then | ||
echo -e "\e[1m\e[39m[\e[31mTEST FAILED\e[39m] \e[21mNo scripts could be found\e[21m! \e[0m" | ||
exit 1 | ||
fi | ||
|
||
rm -f tmp/tmperr | ||
touch tmp/tmperr | ||
|
||
echo | ||
echo "building ..." | ||
|
||
for file in ${MANIFEST[@]}; | ||
do | ||
SRC_PATH=$(dirname ${file})/ | ||
OBJ_PATH=${SRC_PATH/src/obj} | ||
OBJ_LUA=$(basename ${file}) | ||
OBJ_LUAC=${OBJ_LUA/.lua/.luac} | ||
|
||
echo | ||
echo -ne "\e[1m\e[37m${file}\e[39m\e[1m\e[0m ...\e[0m" | ||
|
||
mkdir -p ${OBJ_PATH} | ||
|
||
|
||
if [[ $MINIFY == "min" ]]; then | ||
if [[ $EXCLUDE && ($(printf "_[%s]_" "${EXCLUDE[@]}") =~ .*_\[$file\]_.*) ]]; then | ||
cp -f "$file" "${OBJ_PATH}${OBJ_LUA}" | ||
else | ||
echo -n " minify ..." | ||
node node_modules/luamin/bin/luamin -f "$file" > "${OBJ_PATH}${OBJ_LUA}" | ||
fi | ||
else | ||
cp -f "$file" "${OBJ_PATH}${OBJ_LUA}" | ||
fi | ||
|
||
echo -n " compile ..." | ||
luac -s -o "${OBJ_PATH}${OBJ_LUAC}" "$file" >tmp/tmpvar 2>tmp/tmpvar | ||
STDOUT=$(<tmp/tmpvar) | ||
rm -f tmp/tmpvar | ||
|
||
_fail=$? | ||
if [[ $_fail -ne 0 || $STDOUT ]]; then | ||
((ERRCNT++)) | ||
echo | ||
echo `date +"%Y-%m-%d %T"` "$file $STDOUT"$'\r' >>tmp/tmperr | ||
echo -e "\e[1m\e[39m[\e[31mBUILD FAILED\e[39m] \e[1m \e[0m\e[37mCompilation error:\e[0m" | ||
echo -e "\e[1m\e[37m${STDOUT}\e[39m\e[1m\e[0m \e[0m" | ||
else | ||
echo -ne " \e[1m\e[39m[\e[32mok\e[39m]\e[1m\e[0m\e[0m" | ||
fi | ||
done | ||
|
||
LAST_FAILURES=$(<tmp/tmperr) | ||
|
||
rm -dfR tmp | ||
|
||
echo | ||
if [[ $LAST_FAILURES == '' ]]; then | ||
if [ -f bin/attachments.sh ]; then | ||
echo | ||
echo "copying attachments..." | ||
bash bin/attachments.sh | ||
fi | ||
|
||
echo | ||
echo -e "\e[1m\e[39m[\e[32mSUCCESSFUL\e[39m] \e[21mAll lua files built successfully!\e[21m\e[1m\e[0m\e[0m" | ||
else | ||
echo "$LAST_FAILURES"$'\r' >> ".builderr" | ||
echo | ||
echo -e "\e[1m\e[39m[\e[31mBUILD FAILED\e[39m] \e[1m \e[0m\e[37mCompilation error(s):\e[0m" | ||
echo -e "\e[1m\e[37m${LAST_FAILURES}\e[39m\e[1m\e[0m \e[0m"$'\r' | ||
fi | ||
|
||
echo | ||
exit $ERRCNT |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
{ | ||
"name": "betaflight-tx-lua-scripts", | ||
"version": "1.3.0", | ||
"scripts": { | ||
"start": "bash bin/build.sh min" | ||
}, | ||
"description": "", | ||
"devDependencies": { | ||
"luamin": "^1.0.4" | ||
} | ||
} |
Oops, something went wrong.