mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-26 14:51:52 +03:00
0154018363
* FBT: cdefines to env, libs order * API: strtod, modf, itoa, calloc * Apps: elk js * Apps: mjs * JS: scripts as assets * mjs: composite resolver * mjs: stack trace * ELK JS example removed * MJS thread, MJS lib modified to support script interruption * JS console UI * Module system, BadUSB bindings rework * JS notifications, simple dialog, BadUSB demo * Custom dialogs, dialog demo * MJS as system library, some dirty hacks to make it compile * Plugin-based js modules * js_uart(BadUART) module * js_uart: support for byte array arguments * Script icon and various fixes * File browser: multiple extensions filter, running js scripts from app loader * Running js scripts from archive browser * JS Runner as system app * Example scripts moved to /ext/apps/Scripts * JS bytecode listing generation * MJS builtin printf cleanup * JS examples cleanup * mbedtls version fix * Unused lib cleanup * Making PVS happy & TODOs cleanup * TODOs cleanup #2 * MJS: initial typed arrays support * JS: fix mem leak in uart destructor Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
37 lines
1.2 KiB
C
37 lines
1.2 KiB
C
#include <core/common_defines.h>
|
|
#include "../js_modules.h"
|
|
#include <furi_hal_version.h>
|
|
#include <power/power_service/power.h>
|
|
|
|
static void js_flipper_get_model(struct mjs* mjs) {
|
|
mjs_val_t ret = mjs_mk_string(mjs, furi_hal_version_get_model_name(), ~0, true);
|
|
mjs_return(mjs, ret);
|
|
}
|
|
|
|
static void js_flipper_get_name(struct mjs* mjs) {
|
|
const char* name_str = furi_hal_version_get_name_ptr();
|
|
if(name_str == NULL) {
|
|
name_str = "Unknown";
|
|
}
|
|
mjs_val_t ret = mjs_mk_string(mjs, name_str, ~0, true);
|
|
mjs_return(mjs, ret);
|
|
}
|
|
|
|
static void js_flipper_get_battery(struct mjs* mjs) {
|
|
Power* power = furi_record_open(RECORD_POWER);
|
|
PowerInfo info;
|
|
power_get_info(power, &info);
|
|
furi_record_close(RECORD_POWER);
|
|
mjs_return(mjs, mjs_mk_number(mjs, info.charge));
|
|
}
|
|
|
|
void* js_flipper_create(struct mjs* mjs, mjs_val_t* object) {
|
|
mjs_val_t flipper_obj = mjs_mk_object(mjs);
|
|
mjs_set(mjs, flipper_obj, "getModel", ~0, MJS_MK_FN(js_flipper_get_model));
|
|
mjs_set(mjs, flipper_obj, "getName", ~0, MJS_MK_FN(js_flipper_get_name));
|
|
mjs_set(mjs, flipper_obj, "getBatteryCharge", ~0, MJS_MK_FN(js_flipper_get_battery));
|
|
*object = flipper_obj;
|
|
|
|
return (void*)1;
|
|
}
|