We’re excited to announce VEE Script, a new scripting language for the Virtual Execution Environment (VEE). VEE Script, a streamlined subset of JavaScript, is optimized for dynamic evaluations, making it ideal for applications like smartwatches and smart home devices.
“We developed VEE Script in response to market demand for lightweight, efficient solutions that streamline real-time data display on user interfaces without the complexity of full-scale software platforms. This scripting language, a subset of JavaScript, prioritizes dynamic evaluation and flexibility, ensuring optimal performance across diverse hardware environments.” Said Andy Poudret, Embedded Software Engineer, MicroEJ.
Key Benefits of VEE Scrip
1.Subset of JavaScript for Efficiency VEE Script includes most JavaScript expressions but omits statements and blocks. This focused approach reduces complexity, making VEE Script lightweight and efficient for dynamic evaluations without sacrificing the flexibility developers need.
2.Preprocessing for Enhanced Performance Expressions in VEE Script are preprocessed on a PC. During this phase, they are parsed, converted into an Abstract Syntax Tree (AST), and serialized into a binary file. At runtime, these ASTs are deserialized and evaluated dynamically, ensuring that your applications run smoothly and efficiently.
3.Dynamic Evaluation for displaying data in real-time One of the standout features of VEE Script is its ability to dynamically evaluate expressions based on the runtime context. This means that the value of an expression can change in real-time, allowing for highly responsive and adaptable scripting, perfect for interactive user interfaces.
4.Custom Tags and Functions VEE Script allows developers to define custom tags and functions tailored to their specific device requirements. Whether it’s a smartwatch, washing machine, or smart home device, VEE Script can be customized to handle a wide range of data and operations efficiently.
5.Type Flexibility Once evaluated, expression values in VEE Script can be boolean, number, or string, and can be converted between these types as needed. This flexibility ensures that VEE Script can handle diverse data types and operations seamlessly.
VEE Script vs. JavaScript: What Sets Them Apart?
While both VEE Script and JavaScript are powerful tools, they serve different purposes:
- Feature Set: VEE Script is designed to evaluate expressions, not execute full statements or instructions, making it simpler and more focused.
- Data Representation: VEE Script represents expressions as data that can be interpreted without executing code dynamically, whereas JavaScript scripts are usually converted into managed code embedded in the firmware or application.
- Resource Efficiency: The VEE Script engine is more lightweight in terms of ROM and RAM usage and offers better performance compared to JavaScript, making it ideal for resource-constrained environments.
If you need the full power of expression of JavaScript, MicroEJ has a runtime implementation of Javascript called Kirafu. More information about MICROEJKifaru: https://www.microej.com/microej-kifaru-javascript-development-environment-for-embedded-devices/
Use Cases: Practical Applications of VEE Script
Smartwatch Interfaces
- Dynamic Battery Indicator: Utilize a custom tag to dynamically showcase the remaining battery percentage.
- Real-Time Health Data: Display heart rate, temperature, and weather conditions (sunny/cloudy) using custom tags.
Washing Machine Controls
- Water Temperature Display: Update the display dynamically with a tag reflecting water temperature changes.
- Cycle Progress Indicator: Use conditional operations to indicate various cycle stages based on sensor feedback.
Smart Home Devices
- Ambient Temperature or Humidity Display: Utilize VEE Script to showcase real-time environmental data.
- Energy Consumption Monitoring: Employ functions to monitor and display energy usage in real-time.
Examples
- This example script dynamically retrieves and displays the current heart rate from a smartwatch device. It fetches the heart rate value using the getValueForTag function and appends ” BPM” to indicate beats per minute.
device.getValueForTag('HEART_RATE') + ' BPM'
- This script animates the position of a widget based on real-time data. It utilizes the sine function (sin) to create a smooth oscillating effect synchronized with the current time fetched from the device.
runFunction('sin', device.getValueForTag('CURRENT_TIME')/1000*3.14) * 100
VEE Script is currently part of our VEE Wear framework and will be used in our coming vertical frameworks. We invite you to explore the possibilities with VEE Script in VEE Wear and see how it can enhance your projects. Stay tuned for more updates and detailed tutorials on how to get the most out of this powerful new tool!