1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-18 22:05:10 +03:00
Commit graph

43 commits

Author SHA1 Message Date
3djc
e7d7f9df95 Fix some events not sent to LUA telemetry scripts scripts.
Thix fixes #4366
2017-02-02 08:02:18 +01:00
Damjan Adamic
82dce3ee60 Projectkk2glider/flash savings (#4199)
* Flash savings: getFileExtension() de-templated, saves 160 bytes

* Flash savings: several variables moved to rodata, RGB macro optimization (speed and can now be used to initialize rodata)

Result for Horus:
   text	   data	    bss	    dec
1261182	 808603	  42020	2111805   before
1267149	 803335	  42124	2112608   after (data size also counts .sram section)

5kB saved in .data section (RAM and FLASH)

* Removed compiler warnings

* RGB() and ARGB() gtests added

* ARGB() optimized
2017-01-05 21:44:59 +01:00
Max Paperno
5d5dc67605 Add runtime Lua script pre-compilation and general .luac file support (#3318) (#4119)
* [simu] simpgmspace: Populate file date/time/size  in f_stat(); Add f_utime(); Fix f_getcwd() on Windows; Fix f_mkdir() build error on Windows.

* [Lua] Add runtime support for script pre-compilation. Changes behavior with LUA_COMPILER (Re: https://github.com/opentx/opentx/issues/3318):
  All .lua scripts are now compiled and saved to binary "bytecode" file (.luac extension) upon first execution;
  Scripts are also automatically re-compiled if .lua source file is newer than existing .luac file;
  The pre-compiled .luac version is loaded if modification time is newer or equivalent to .lua source file;
  If a .luac version of a script exists, then the .lua version does not need to be present;
  Guards against bytecode compatibility issues (binaries from 64-bit sim will not run on 32-bit sim/radio);
  In SIMU and DEBUG builds, the source .lua file is always preferred in order to preserve full debug info (this is is controlled with new LUA_SCRIPT_LOAD_MODE macro, see lua_api.h);
  GC is now run after each script is loaded.

* [Lua] Add loadScript() API function as alternative to loadfile() from Lua base. This can take advantage of the new OTx script pre-compilation features to reduce memory footprint when loading functions dynamically. This is an interface to luaLoadScriptFileToState(). Fully documented.

* [SD][Lua] Flexible file extensions support:
  Allow for variable length file extensions throughout system (no longer hard-coded in LEN_FILE_EXTENSION);
  Fixes issues with renaming files in SD manager which have file extensions longer than ".ext";
  Expand general support for multiple file extensions per file type in sdListFiles() (eg. .lua and .luac for scripts);
  Lua scripts with .luac extensions can now be selected in custom/telemetry/function menus even if no .lua version exists (duplicates are not shown);
  .luac files can now also be executed from SD file manager UI.

* [Build] Added CMake options for LUA_COMPILER and LUA_SCRIPT_LOAD_MODE.

* Cosmetics.

* [SD][gui] Improve efficiency of some file name handling routines in sdmanager GUI and sdListFiles() by extending getFileExtension() function. Use shared isExtensionMatching() in place of isImageFileExtension(). Only allow executing .luac files when LUA_COMPILER defined (as per request).

* [simpgmspace] Fix f_mkdir() for MSVC build and misc. cleanup.

* [Lua] Use getFileExtension() in script loader to determine file type and check for buffer overflow.
2016-12-17 10:56:40 +01:00
Bertrand Songis
c23ac292b7 [Companion] Horus simulator fixes 2016-12-02 19:56:41 +01:00
Damjan Adamic
92553b6589 Projectkk2glider/lua bitmap free (#4075)
* Better memory stats (CLI)

* Bitmap buffer overflow check added

* Lua bitmap improvements

* Proper handling of symbolic links in simulator

* S6R Lua script fixes:
 * added progress screen while loading bitmaps
 * memory for bitmaps is now freed when leaving the script

* S6R Lua script: improved bitmap loading

* * Lua Themes and Widgets moved to separate file and separate Lua state
* Stand-alone, mixer and function scripts now behave the same as on Taranis (restarted after the stand-alone script was run)
* both Lua states are independent: Themes and Widgets is initialized only at the start, the other one is initialized before and after the stand-alone script is run

* Better leak test and report in BitmapBuffer

* Re #3318: Lua compiler enabled in simu and Companion simulator. Usage:
 * any time <xxx>.lua file is about to be loaded and if file <xxx>.lua.src exists:
   * load contents of <xxx>.lua.src
   * compile Lua code
   * save compiled code into <xxx>.lua (effectively overwrites existing file)
 * immediately following the compilation the real file loading is done from <xxx>.lua (which by now contains compiled Lua bytecode)
2016-11-28 23:08:18 +01:00
Bertrand Songis
d58244ebde Bsongis/lua interpreter added on x7d (#3999)
* [X7D] Lua option added (only standalone scripts)

* [X7D] Compilation fix

* [X7D] Compilation fix

* [X7D] Compilation fix

* [X7D] Compilation fix
2016-11-10 21:41:16 +01:00
3djc
4825ffe2f3 Cosmetics 2016-10-23 14:44:07 +02:00
3djc
cff0b33f4b Cosmetics 2016-10-23 14:42:59 +02:00
3djc
4f24088719 Enable permanent scripts on Horus 2016-10-23 14:41:05 +02:00
Damjan Adamic
4513cf89f2 Projectkk2glider/fatfs 0.12 (#3925)
* Re #3815: Disk cache: Write statistic added. Bigger disk cache. Show disk cache misses in CLI.

* Update to the latest FatFS R0.12b (all existing OpenTX patches have been already applied in upstream, only few ff.h modifications needed for simulator)

* Missing file

* SD card manager: do not show parent dir [..] for root directory
2016-10-18 18:14:17 +02:00
Damjan Adamic
88e1740422 Fixes #3882: Widget option min an max values were not parsed (resulted in Lua disabled) 2016-10-07 15:18:49 +02:00
Bertrand Songis
4a88d3477d Fixes #3766 2016-09-13 18:31:57 +02:00
3djc
d84fd993c9 Move lua evt param from signed uint8_t to unsigned event_t 2016-09-12 07:20:06 +02:00
Bertrand Songis
d3ae3c035d Bsongis/gui refactoring for x7 d (#3701)
* [X7D] New board added
* Cosmetics
2016-08-18 11:49:16 +02:00
Bertrand Songis
7fbd963b3f Another big refactoring 2016-08-02 22:15:29 +02:00
Bertrand Songis
400faee588 Refactoring 2016-08-01 20:25:20 +02:00
3djc
2f8effb6d1 Add function name to debug output (#3647)
* Add function name to debug output

* Better english, hopefully :)

* Possible fix for not trying to run background widgets function when it does not exist

* Typos
2016-07-06 18:41:45 +02:00
Bertrand Songis
38fdae6f1f Fixes #3609 - ``background()`` function in Lua function scripts 2016-06-22 18:32:51 +02:00
Bertrand Songis
5822cfded1 [Horus] Options in widgets can now have a min and a max defined 2016-06-07 20:35:17 +02:00
Bertrand Songis
231499e191 [Horus] Bitmap class and lcd.drawBitmap() added 2016-05-25 11:48:38 +02:00
Bertrand Songis
7a2c0b3b88 [Horus] Widget::update added to the Lua interface (called when options are modified) 2016-05-21 11:08:01 +02:00
Bertrand Songis
633af68fa9 [Horus] background function added to widgets 2016-05-18 18:49:06 +02:00
Damjan Adamic
7d57b4df05 Compilation fix 2016-04-07 21:27:00 +02:00
Bertrand Songis
ecff71b044 Cosmetics 2016-03-25 12:54:35 +01:00
Bertrand Songis
7e45537402 [Horus] Keymap is now consistent with labels on keys 2016-03-15 23:21:32 +01:00
Bertrand Songis
55f71f053b myeeprom.h splitted into dataconstants.h and datastructs.h 2016-03-04 23:54:35 +01:00
Bertrand Songis
52a52fdb8a Memory leak in the simu (thanks Valgrind) 2016-02-29 19:20:56 +01:00
Bertrand Songis
2b9242fac2 [Horus] GUI continued 2016-02-25 23:14:58 +01:00
Bertrand Songis
358badfed9 [Horus] Bitmaps dynamic load 2016-02-21 18:25:52 +01:00
Bertrand Songis
67a599e0b9 [CLI] reboot command added 2016-02-20 16:55:05 +01:00
Bertrand Songis
84bf31f908 Compilation error 2016-02-19 07:13:53 +01:00
Bertrand Songis
d1be1b4ea0 [Horus] Widgets can be written in Lua 2016-02-18 22:10:27 +01:00
Bertrand Songis
f9f7ddd639 [Horus] Alert Box new design by Martin 2016-02-16 22:07:33 +01:00
Bertrand Songis
33910c8721 [Horus] UI continued 2016-02-16 20:45:25 +01:00
Damjan Adamic
51b8f9b054 Re #2469: part1: Menu system renaming of variables and refactoring (ported #3087 from master commits 3186a5d99..94d8b8b0e8d) 2015-11-26 18:29:20 +01:00
Bertrand Songis
71f08998dd [Horus] No more errors in Lua interface compilation 2015-11-25 21:50:12 +01:00
Bertrand Songis
791b1173e3 Another couple of functions renamed
And nothing else this time!
2015-11-25 21:24:20 +01:00
Bertrand Songis
01187e60c2 Some more LCD functions renamed 2015-11-24 22:09:22 +01:00
dsbeach
a1bb31b521 Modifications to luaCompileAndSave() - as scripts are loaded it will check for existing file <file>.lua.src and compile it to <file>.lua if found. (ported from master, re #3079) 2015-11-19 17:50:07 +01:00
Bertrand Songis
de733579d5 Merge remote-tracking branch 'origin/next' into Horus
# Conflicts:
#	companion/src/CMakeLists.txt
#	companion/src/firmwares/opentx/opentxinterface.cpp
#	companion/src/firmwares/opentx/simulator/CMakeLists.txt
#	companion/src/firmwares/opentx/stamp-opentx.h.in
#	radio/src/Makefile
#	radio/src/cli.cpp
#	radio/src/gui/Taranis/helpers.cpp
#	radio/src/gui/Taranis/lcd.cpp
#	radio/src/gui/Taranis/menu_model_setup.cpp
#	radio/src/gui/Taranis/view_main.cpp
#	radio/src/lua_api.cpp
#	radio/src/main_avr.cpp
#	radio/src/myeeprom.h
#	radio/src/opentx.cpp
#	radio/src/pulses/pxx_arm.cpp
#	radio/src/storage/eeprom_conversions.cpp
#	radio/src/targets/Horus/adc_driver.cpp
#	radio/src/targets/Horus/board_horus.cpp
#	radio/src/targets/Horus/board_horus.h
#	radio/src/targets/Horus/diskio.cpp
#	radio/src/targets/Horus/hal.h
#	radio/src/targets/Horus/haptic_driver.cpp
#	radio/src/targets/Horus/i2c_driver.cpp
#	radio/src/targets/Horus/keys_driver.cpp
#	radio/src/targets/Horus/lcd_driver.cpp
#	radio/src/targets/Horus/led_driver.cpp
#	radio/src/targets/Horus/pulses_driver.cpp
#	radio/src/targets/Horus/pwr_driver.c
#	radio/src/targets/Horus/sdio_sd.c
#	radio/src/targets/Horus/sdio_sd.h
#	radio/src/targets/Horus/serial2_driver.cpp
#	radio/src/targets/Horus/telemetry_driver.cpp
#	radio/src/targets/Horus/usb_conf.h
#	radio/src/targets/Horus/usbd_desc.c
#	radio/src/targets/Horus/usbd_storage_msd.cpp
2015-11-15 23:08:34 +01:00
Damjan Adamic
754b875d81 Re #3054: Lua byte-code of every loaded script is dumped to a file if LUA_COMPILER=YES is defined (only for simu target. Original code author (dsbeach) 2015-11-15 16:32:12 +01:00
Damjan Adamic
feac6d000f Companion build fixed (stamp duplication removed) 2015-11-15 13:19:26 +01:00
Damjan Adamic
d54f25ccba Lua api and interface lua_api.cpp moved to lua dir and split into several files 2015-11-15 12:05:53 +01:00