code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
/* * Tiny arbitrary precision floating point library * * Copyright (c) 2017-2020 Fabrice Bellard * * 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 withou...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/libbf.c
C
apache-2.0
239,756
/* * Tiny arbitrary precision floating point library * * Copyright (c) 2017-2020 Fabrice Bellard * * 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 withou...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/libbf.h
C
apache-2.0
17,831
/* * Regular Expression Engine * * Copyright (c) 2017-2018 Fabrice Bellard * * 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 righ...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/libregexp-opcode.h
C
apache-2.0
2,236
/* * Regular Expression Engine * * Copyright (c) 2017-2018 Fabrice Bellard * * 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 righ...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/libregexp.c
C
apache-2.0
83,760
/* * Regular Expression Engine * * Copyright (c) 2017-2018 Fabrice Bellard * * 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 righ...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/libregexp.h
C
apache-2.0
3,129
/* * Unicode utilities * * Copyright (c) 2017-2018 Fabrice Bellard * * 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...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/libunicode.c
C
apache-2.0
46,403
/* * Unicode utilities * * Copyright (c) 2017-2018 Fabrice Bellard * * 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...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/libunicode.h
C
apache-2.0
3,751
// // jquick_mutex.c // // Copyright (C) 2015-2021 Alibaba Group Holding Limited. // #include "linux_jquick_mutex.h" #include <stdio.h> #include <pthread.h> #include <stdlib.h> JQuick_Mutex jquick_mutex_create() { JQuick_Mutex mutex = (JQuick_Mutex)malloc(sizeof(pthread_mutex_t)); if (!mutex) { printf...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/linux_jquick_mutex.c
C
apache-2.0
1,247
#ifndef __AOS_AMP_JQUICK_MUTEX_H__ #define __AOS_AMP_JQUICK_MUTEX_H__ #ifdef __cplusplus extern "C" { #endif typedef void* JQuick_Mutex; JQuick_Mutex jquick_mutex_create(); int jquick_mutex_lock( JQuick_Mutex m); int jquick_mutex_unlock( JQuick_Mutex m); int jquick_mutex_destroy( JQuick_M...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/linux_jquick_mutex.h
C
apache-2.0
403
/* * Linux klist like system * * Copyright (c) 2016-2017 Fabrice Bellard * * 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 ...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/list.h
C
apache-2.0
3,228
/* * QuickJS stand alone interpreter * * Copyright (c) 2017-2020 Fabrice Bellard * Copyright (c) 2017-2020 Charlie Gordon * * 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 res...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/qjs.c
C
apache-2.0
16,502
/* * QuickJS command line compiler * * Copyright (c) 2018-2020 Fabrice Bellard * * 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 ...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/qjsc.c
C
apache-2.0
20,655
/* * QuickJS Javascript Calculator * * Copyright (c) 2017-2020 Fabrice Bellard * * 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 ...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/qjscalc.js
JavaScript
apache-2.0
72,796
/* * QuickJS atom definitions * * Copyright (c) 2017-2018 Fabrice Bellard * Copyright (c) 2017-2018 Charlie Gordon * * 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 restricti...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/quickjs-atom.h
C
apache-2.0
7,886
/* * QuickJS C library * * Copyright (c) 2017-2020 Fabrice Bellard * Copyright (c) 2017-2020 Charlie Gordon * * 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, incl...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/quickjs-libc.c
C
apache-2.0
108,121
/* * QuickJS C library * * Copyright (c) 2017-2018 Fabrice Bellard * * 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...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/quickjs-libc.h
C
apache-2.0
2,399
/* * QuickJS opcode definitions * * Copyright (c) 2017-2018 Fabrice Bellard * Copyright (c) 2017-2018 Charlie Gordon * * 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 restric...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/quickjs-opcode.h
C
apache-2.0
15,331
/* * QuickJS Javascript Engine * * Copyright (c) 2017-2020 Fabrice Bellard * Copyright (c) 2017-2020 Charlie Gordon * * 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 restricti...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/quickjs.h
C
apache-2.0
40,726
#!/bin/sh # Release the QuickJS source code set -e version=`cat VERSION` if [ "$1" = "-h" ] ; then echo "release.sh [all]" echo "" echo "all: build all the archives. Otherwise only build the quickjs source archive." exit 1 fi extras="no" binary="no" quickjs="no" if [ "$1" = "all" ] ; then extra...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/release.sh
Shell
apache-2.0
2,421
/* * QuickJS Read Eval Print Loop * * Copyright (c) 2017-2020 Fabrice Bellard * Copyright (c) 2017-2020 Charlie Gordon * * 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 restr...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/repl.js
JavaScript
apache-2.0
49,267
/* * ECMA Test 262 Runner for QuickJS * * Copyright (c) 2017-2020 Fabrice Bellard * Copyright (c) 2017-2020 Charlie Gordon * * 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 r...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/run-test262.c
C
apache-2.0
62,367
/* * QuickJS: binary JSON module (test only) * * Copyright (c) 2017-2019 Fabrice Bellard * * 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 limit...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/bjson.c
C
apache-2.0
3,139
/* * Javascript Micro benchmark * * Copyright (c) 2017-2019 Fabrice Bellard * Copyright (c) 2017-2019 Charlie Gordon * * 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 restrict...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/microbench.js
JavaScript
apache-2.0
23,224
"use strict"; function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && actual.toString() === expected.toString...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_bignum.js
JavaScript
apache-2.0
10,143
import * as bjson from "./bjson.so"; function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && actual.toString(...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_bjson.js
JavaScript
apache-2.0
5,224
"use strict"; function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && actual.toString() === expected.toString...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_builtin.js
JavaScript
apache-2.0
16,513
function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && actual.toString() === expected.toString()) ret...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_closure.js
JavaScript
apache-2.0
4,359
function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && actual.toString() === expected.toString()) ret...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_language.js
JavaScript
apache-2.0
7,438
function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && actual.toString() === expected.toString()) ret...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_loop.js
JavaScript
apache-2.0
6,286
"use strict"; function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && actual.toString() === expected.toString...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_op_overloading.js
JavaScript
apache-2.0
4,581
"use math"; "use strict"; function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && actual.toString() === expec...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_qjscalc.js
JavaScript
apache-2.0
5,876
import * as std from "std"; import * as os from "os"; function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof expected == 'object' && ...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_std.js
JavaScript
apache-2.0
6,776
/* os.Worker API test */ import * as std from "std"; import * as os from "os"; function assert(actual, expected, message) { if (arguments.length == 1) expected = true; if (actual === expected) return; if (actual !== null && expected !== null && typeof actual == 'object' && typeof exp...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/tests/test_worker.js
JavaScript
apache-2.0
2,447
#!/bin/sh set -e url="ftp://ftp.unicode.org/Public/13.0.0/ucd" emoji_url="${url}/emoji/emoji-data.txt" files="CaseFolding.txt DerivedNormalizationProps.txt PropList.txt \ SpecialCasing.txt CompositionExclusions.txt ScriptExtensions.txt \ UnicodeData.txt DerivedCoreProperties.txt NormalizationTest.txt Scripts.txt \ Pr...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/unicode_download.sh
Shell
apache-2.0
485
/* * Generation of Unicode tables * * Copyright (c) 2017-2018 Fabrice Bellard * Copyright (c) 2017-2018 Charlie Gordon * * 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 restr...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/unicode_gen.c
C
apache-2.0
83,240
#ifdef UNICODE_GENERAL_CATEGORY DEF(Cn, "Unassigned") /* must be zero */ DEF(Lu, "Uppercase_Letter") DEF(Ll, "Lowercase_Letter") DEF(Lt, "Titlecase_Letter") DEF(Lm, "Modifier_Letter") DEF(Lo, "Other_Letter") DEF(Mn, "Nonspacing_Mark") DEF(Mc, "Spacing_Mark") DEF(Me, "Enclosing_Mark") DEF(Nd, "Decimal_Number,digit") DEF...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/quickjs/unicode_gen_def.h
C
apache-2.0
6,840
#include "amp_config.h" #include "aos/list.h" #include "aos_system.h" #include "quickjs-libc.h" #include "quickjs.h" #include "quickjs_addon.h" #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <string.h> #define MOD_STR "QUICKJS_INIT" static JSRuntime *rt = NULL; static JSContext *ctx = NULL; stat...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/startup/quickjs_init.c
C
apache-2.0
10,059
#include <stdio.h> #include <stdint.h> #include <stdbool.h> #include "quickjs.h" #include "amp_config.h" #include "amp_defines.h" #include "aos/list.h" #include "quickjs-libc.h" #include "aos_system.h" #define MOD_STR "quickjs_module_load" static dlist_t g_prebuild_module_list = AOS_DLIST_HEAD_INIT(g_prebuild_module_...
YifuLiu/AliOS-Things
components/amp/engine/quickjs_engine/startup/quickjs_module_load.c
C
apache-2.0
3,716
/* * Copyright (C) 2015-2020 Alibaba Group Holding Limited */ #include <stdio.h> #include <stdarg.h> extern int amp_main(); int main(void) { amp_main(); }
YifuLiu/AliOS-Things
components/amp/entry/amp_entry.c
C
apache-2.0
164
import * as AIOT_DEVICE from 'AIOT_DEVICE'; import * as fs from 'FS'; import * as kv from 'kv'; import * as adc from 'ADC'; import * as pwm from 'PWM'; import * as NETMGR from 'NETMGR'; var pwm2 = pwm.open('PWM2'); var adc0 = adc.open('adc0'); var adc7 = adc.open('adc7'); NETMGR.serviceInit(); var dev_handler = NETMG...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/adcsample/app.js
JavaScript
apache-2.0
3,428
import * as AIOT_DEVICE from 'AIOT_DEVICE'; import * as fs from 'FS'; import * as kv from 'kv'; import * as adc from 'ADC'; import * as NETMGR from 'NETMGR'; import * as fire from './fire_mk002354.js'; var adcDev = adc.open('fire'); var fireDev = fire.Fire(adcDev); NETMGR.serviceInit(); var dev_handler = NETMGR.getDe...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/fire_detector/app.js
JavaScript
apache-2.0
2,949
class _Fire { constructor(adcObj) { this.adcInstance = adcObj; }; getVoltage() { var value = this.adcInstance.read(); return value; }; } export function Fire(adcObj) { return new _Fire(adcObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/fire_detector/fire_mk002354.js
JavaScript
apache-2.0
228
import * as AIOT_DEVICE from 'AIOT_DEVICE'; import * as fs from 'FS'; import * as kv from 'kv'; import * as i2c from 'i2c' import * as NETMGR from 'NETMGR'; import * as sht3x from './sht3x.js'; import * as gpio from 'GPIO'; var temperature = 25.0; var humidity = 0.0; var airconditioner_value = 0; var humidifier_value ...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/floriculture/app.js
JavaScript
apache-2.0
4,185
class _SHT3X { constructor(i2cObj) { this.i2cInstance = i2cObj; var cmd = [0x30, 0x41]; //console.log('init cmd = ' + cmd); this.i2cInstance.write(cmd); sleepMs(20); }; getTempHumidity() { var sensorData = [0x0, 0x0]; var cmd = [0x24, 0x0b]; //console.log('get data cmd =...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/floriculture/sht3x.js
JavaScript
apache-2.0
1,339
import * as AIOT_DEVICE from 'AIOT_DEVICE'; import * as fs from 'FS'; import * as kv from 'kv'; import * as adc from 'ADC'; import * as NETMGR from 'NETMGR'; import * as gas from './gas.js'; import * as gpio from 'GPIO'; var adcDev = adc.open('gas'); var gasDev = gas.Gas(adcDev); /* open GPIO led */ var ledDev = gpio....
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/gas_detector/app.js
JavaScript
apache-2.0
3,029
class _Gas { constructor(adcObj) { this.adcInstance = adcObj; }; getVoltage() { var value = this.adcInstance.read(); return value; }; } export function Gas(adcObj) { return new _Gas(adcObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/gas_detector/gas.js
JavaScript
apache-2.0
225
import * as AIOT_DEVICE from 'AIOT_DEVICE'; import * as fs from 'FS'; import * as kv from 'kv'; import * as adc from 'ADC'; import * as NETMGR from 'NETMGR'; import * as hcho from './hcho.js'; var adcDev = adc.open('hcho'); var hchoDev = hcho.Hcho(adcDev); NETMGR.serviceInit(); var dev_handler = NETMGR.getDev('/dev/w...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/hcho_detector/app.js
JavaScript
apache-2.0
2,764
class _Hcho { constructor(adcObj) { this.adcInstance = adcObj; }; getPPM() { var min = 400; var max = 0; var value = 0; var total = 0; var analogVoltage = 0; var ppm = 0; for (var i = 0; i < 32; i++) { var value = this.adcInstance.read(); //console.log('value is ' + value); total ...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/hcho_detector/hcho.js
JavaScript
apache-2.0
1,027
setInterval(function() { console.log('helloworld'); }, 1000);
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/helloworld/app.js
JavaScript
apache-2.0
65
import * as AIOT_DEVICE from 'AIOT_DEVICE'; import * as fs from 'FS'; import * as kv from 'kv'; import * as NETMGR from 'NETMGR'; import * as gpio from 'GPIO'; import * as ir from './ir.js' /* open GPIO ir */ var irObj = gpio.open('ir'); var irDev = ir.IR(irObj); /* open GPIO led */ var ledDev = gpio.open('led'); NET...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/human_detector/app.js
JavaScript
apache-2.0
3,119
class _IR { constructor(gpioObj) { this.gpioInstance = gpioObj; }; irDetect() { var value = this.gpioInstance.read(); return value; }; } export function IR(gpioObj) { return new _IR(gpioObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/human_detector/ir.js
JavaScript
apache-2.0
226
import * as AIOT_DEVICE from 'AIOT_DEVICE'; import * as fs from 'FS'; import * as kv from 'kv'; import * as adc from 'ADC'; import * as NETMGR from 'NETMGR'; import * as photoresistor from './photoresistor.js'; import * as gpio from 'GPIO'; var adcDev = adc.open('photoresistor'); var photoresistorDev = photoresistor.P...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/smart_public_lighting/app.js
JavaScript
apache-2.0
3,160
class _PhotoResistor { constructor(adcObj) { this.adcInstance = adcObj; }; getLightness() { var value = this.adcInstance.read(); return value; }; } export function PhotoResistor(adcObj) { return new _PhotoResistor(adcObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/smart_public_lighting/photoresistor.js
JavaScript
apache-2.0
257
import * as AIOT_DEVICE from 'AIOT_DEVICE'; import * as fs from 'FS'; import * as kv from 'kv'; import * as uart from 'UART'; import * as NETMGR from 'NETMGR'; import * as gps from './gps.js'; NETMGR.serviceInit(); var dev_handler = NETMGR.getDev('/dev/wifi0'); var device; /* 1. WIFI配网,连接路由器 */ var keySSID = 'oneMinu...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/vehicle_location/app.js
JavaScript
apache-2.0
3,241
/** * @license GPS.js v0.6.0 26/01/2016 * * Copyright (c) 2016, Robert Eisele (robert@xarg.org) * Dual licensed under the MIT or GPL Version 2 licenses. **/ function parseCoord(coord, dir) { if (coord === '') return null; var n, sgn = 1; switch (dir) { case 'S': sgn = ...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/examples/vehicle_location/gps.js
JavaScript
apache-2.0
1,627
import * as adc from 'adc' import * as fire from './fire_mk002354.js' console.log('Testing fire ...'); var adcDev = adc.open({ id: 'fire', success: function() { console.log('adc: open success') }, fail: function() { console.log('adc: open failed') } }); var fireDev = fire.Fire(adcD...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/adc/fire_mk002354/app.js
JavaScript
apache-2.0
443
class _Fire { constructor(adcObj) { this.adcInstance = adcObj; }; getVoltage() { var value = this.adcInstance.readValue(); return value; }; } export function Fire(adcObj) { return new _Fire(adcObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/adc/fire_mk002354/fire_mk002354.js
JavaScript
apache-2.0
233
import * as adc from 'adc' import * as gas from './gas.js' console.log('Testing gas ...'); var adcDev = adc.open({ id: 'gas', success: function() { console.log('adc: open success') }, fail: function() { console.log('adc: open failed') } }); var gasDev = gas.Gas(adcDev); setInterval...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/adc/gas/app.js
JavaScript
apache-2.0
425
class _Gas { constructor(adcObj) { this.adcInstance = adcObj; }; getVoltage() { var value = this.adcInstance.readValue(); return value; }; } export function Gas(adcObj) { return new _Gas(adcObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/adc/gas/gas.js
JavaScript
apache-2.0
230
import * as adc from 'adc' import * as hcho from './hcho.js' console.log('Testing hcho ...'); var adcDev = adc.open({ id: 'hcho', success: function() { console.log('adc: open success'); }, fail: function() { console.log('adc: open failed'); } }); var hchoDev = hcho.Hcho(adcDev); se...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/adc/hcho/app.js
JavaScript
apache-2.0
434
class _Hcho { constructor(adcObj) { this.adcInstance = adcObj; }; getPPM() { var min = 400; var max = 0; var value = 0; var total = 0; var analogVoltage = 0; var ppm = 0; for (var i = 0; i < 32; i++) { var value = this.adcInstance.readValue(); //console.log('value is ' + value); t...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/adc/hcho/hcho.js
JavaScript
apache-2.0
1,032
import * as adc from 'adc' import * as photoresistor from './photoresistor.js' console.log('Testing photoresistor ...'); var adcDev = adc.open({ id: 'photoresistor', success: function() { console.log('adc: open success') }, fail: function() { console.log('adc: open failed') } }); v...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/adc/photoresistor/app.js
JavaScript
apache-2.0
519
class _PhotoResistor { constructor(adcObj) { this.adcInstance = adcObj; }; getLightness() { var value = this.adcInstance.readValue(); return value; }; } export function PhotoResistor(adcObj) { return new _PhotoResistor(adcObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/adc/photoresistor/photoresistor.js
JavaScript
apache-2.0
262
import * as ble_pripheral from 'ble_pripheral' import * as network from 'network'; import * as http from 'http'; import * as fs from 'fs'; import * as kv from 'kv'; console.log('\r\n'); console.log('>>>>>>>>> boot.js >>>>>>>>>'); var key = 'oneMinuteCloudKey'; if(kv.getStorageSync(key) === 'SET') { console.log('KV ...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/bleprph/app.js
JavaScript
apache-2.0
5,570
import * as checksum from 'checksum' import * as crypto from 'crypto' function crypto_test() { let enc_param = { 'key': '000102030405060708090a0b0c0d0e0f', 'in': '3132333435363738' } let enc_result = crypto.encrypt(enc_param); console.log('encrypt:'+enc_result) let dec_param = { 'key': '000102030405060...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/checksum/app.js
JavaScript
apache-2.0
815
import * as fs from 'fs' var path = '/data/jsamp/test.data'; var content = 'this is javascript fs test file'; /** filesystem total size */ console.log('fs total size: ' + fs.totalSize()); /** write file */ fs.writeSync(path, content); console.log('fs write: ' + content); /** used size */ console.log('fs used size: ...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/fs/app.js
JavaScript
apache-2.0
592
import * as gpio from 'gpio' import * as dcmotor from './dcmotor.js' console.log('Testing dcmotor ...'); var gpioDev = gpio.open({ id: 'dcmotor', success: function() { console.log('gpio: open success') }, fail: function() { console.log('gpio: open failed') } }); var dcmotorDev = dc...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/gpio/dcmotor/app.js
JavaScript
apache-2.0
548
class _DCMOTOR { constructor(gpioObj) { this.gpioInstance = gpioObj; }; ctrl(onoff) { this.gpioInstance.writeValue(onoff); }; } export function DCMOTOR(gpioObj) { return new _DCMOTOR(gpioObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/gpio/dcmotor/dcmotor.js
JavaScript
apache-2.0
226
import * as gpio from 'gpio'; var inputobj = gpio.open({ id: 'gpio_input', success: function success() { console.log('gpio: open led success'); }, fail: function fail() { console.log('gpio: open led failed'); } }); setInterval(function() { var value = inputobj.readValue(); console.log('gpio: rea...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/gpio/input/app.js
JavaScript
apache-2.0
355
var gpio = require('gpio'); var irq = gpio.open({ id: 'gpio_irq', success: function() { console.log('gpio: open irq success') }, fail: function() { console.log('gpio: open irq failed') } }); irq.onIRQ({ cb: function() { console.log('gpio: irq interrupt happens'); } });
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/gpio/interrupt/app.js
JavaScript
apache-2.0
296
import * as gpio from 'gpio' import * as ir from './ir.js' console.log('Testing IR detector ...'); var gpioDev = gpio.open({ id: 'ir', success: function() { console.log('gpio: open success') }, fail: function() { console.log('gpio: open failed') } }); var irDev = ir.IR(gpioDev); se...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/gpio/ir/app.js
JavaScript
apache-2.0
429
class _IR { constructor(gpioObj) { this.gpioInstance = gpioObj; }; irDetect() { var value = this.gpioInstance.readValue(); return value; }; } export function IR(gpioObj) { return new _IR(gpioObj); }
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/gpio/ir/ir.js
JavaScript
apache-2.0
231
var gpio = require('gpio'); var output = gpio.open({ id: 'gpio_output', success: function() { console.log('gpio: open output success') }, fail: function() { console.log('gpio: open output failed') } }); var value = 1; setInterval(function() { value = 1 - value; output.writeValue(value); consol...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/gpio/output/app.js
JavaScript
apache-2.0
385
import * as bmp280 from './bmp280.js'; var temperature = 25.0; var pressure = 0.0; bmp280.bmp280_init(); setInterval(function(){ temperature = bmp280.bmp280TemperatureRead(); pressure = bmp280.bmp280PressureRead(); pressure = pressure / 100; // iot needs hPa console.log('Temperature is ' + temperature ...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/i2c/bmp280/app.js
JavaScript
apache-2.0
377
var i2c = require('i2c'); var calibParamT1; var calibParamT2; var calibParamT3; var calibParamP1; var calibParamP2; var calibParamP3; var calibParamP4; var calibParamP5; var calibParamP6; var calibParamP7; var calibParamP8; var calibParamP9; var calibParamT_FINE; const INVALID_TEMP = -273.15; const INVALID_PRESS = 0;...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/i2c/bmp280/bmp280.js
JavaScript
apache-2.0
4,865
import * as i2c from 'i2c' import * as sht3x from './sht3x.js' console.log('Testing sht3x ...'); var i2cDev = i2c.open({ id: 'sht3x', success: function() { console.log('i2c: open success') }, fail: function() { console.log('i2c: open failed') } }); var sht3xDev = sht3x.SHT3X(i2cDev...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/i2c/sht3x/app.js
JavaScript
apache-2.0
697
class _SHT3X { constructor(i2cObj) { this.i2cInstance = i2cObj; var cmd = [0x30, 0x41]; //console.log('init cmd = ' + cmd); this.i2cInstance.write(cmd); sleepMs(20); }; getTempHumidity() { var sensorData = [0x0, 0x0]; var cmd = [0x24, 0x0b]; //console.log('get data cmd =...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/i2c/sht3x/sht3x.js
JavaScript
apache-2.0
1,339
import * as gpio from 'gpio'; import * as network from 'network'; import * as mqtt from 'mqtt'; import * as iot from 'iot'; /* open GPIO LED1 */ var LED1 = gpio.open({ id: 'led', success: function() { console.log('gpio: open LED1 success') }, fail: function() { console.log('gpio: open LED1 failed') }...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/iot/iot-device/sanyuanzu/app.js
JavaScript
apache-2.0
5,156
import * as kv from 'kv' var key = 'key-test'; var value = 'this is amp kv test file'; // kv set kv.setStorageSync(key, value); // kv get var val = kv.getStorageSync(key); console.log('kv read: ' + val); // kv remove kv.removeStorageSync(key);
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/kv/app.js
JavaScript
apache-2.0
248
import * as spi from 'spi'; var W25Q = spi.open({ id: "FLASH", success: function() { console.log('w25q flash open success') }, fail: function() { console.log('w25q flash open failed') } }); /** * 读取flash w25q128 的JEDEC ID值 * * @returns {objct} 返回 JEDEC 值值 */ function getJEDEC() { /* 根据w25q数据手...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/spi/flash_w25q/app.js
JavaScript
apache-2.0
1,876
console.log('system versions().module is: ' + system.versions().module) console.log('system version is: ' + system.version()) console.log('system appversion is: ' + system.appversion()) console.log('system getSystemInfo().userjsVersion is: ' + system.getSystemInfo().userjsVersion) console.log('system getSystemInfo().ap...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/system/app.js
JavaScript
apache-2.0
1,144
/* 加载 timer 模块 */ import * as timer from 'timer' /* 创建 timer 实例 */ var timer0 = timer.open({ id: 'TIMER0' }); console.log('HardWare Timer Test'); /* 定义用来统计触发次数的变量 */ var count = 0; /* 定义定时到期回调函数,单次触发打印一行字符串及触发次数 */ function timeout_cb() { console.log('Timer0 Timeout count' + count); count++; } /* 设置单次定时,...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/timer/app.js
JavaScript
apache-2.0
531
import * as uart from 'uart'; import * as gpsObj from './gps.js'; var gps = gpsObj.GPS(); // gnss uart var gnss = uart.open({ id: 'serial2', success: function() { console.log('gnss open success') }, fail: function() { console.log('gnss open failed') } }); var geoLocation_data = {'l...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/uart/gps_ht2828z3g5l/app.js
JavaScript
apache-2.0
1,344
/** * @license GPS.js v0.6.0 26/01/2016 * * Copyright (c) 2016, Robert Eisele (robert@xarg.org) * Dual licensed under the MIT or GPL Version 2 licenses. **/ (function (root) { 'use strict'; var D2R = Math.PI / 180; var collectSats = {}; var lastSeenSat = {}; function updateState(state, data) { ...
YifuLiu/AliOS-Things
components/amp/example-js/ESP32/jsapi/uart/gps_ht2828z3g5l/gps.js
JavaScript
apache-2.0
24,533
var adc = require('adc'); var vol = adc.open({ id: 'adc1', success: function() { console.log('adc: open adc success') }, fail: function() { console.log('adc: open adc failed') } }); setInterval(function() { console.log('adc: adc value ' + vol.readValue()) }, 2000);
YifuLiu/AliOS-Things
components/amp/example-js/common/adc.js
JavaScript
apache-2.0
291
var at = require('at'); function atTestCallback() { var s = at.atReadLine(-1); /* 从AT串口读一行字符串,参数为读字符串超时时间(单位毫秒,-1表示一直等待) */ at.atSendNoReply("AT+TEST value is " + s.toString() + "\n", 1); /* 发送响应命令,参数分别为: 响应字符串,是否发送命令间隔符 */ } function atWlogpCallback() { var s = at.atRead(1, -1); /* 从AT串口读字符串,第一个参数为读取字符...
YifuLiu/AliOS-Things
components/amp/example-js/common/at.js
JavaScript
apache-2.0
1,612
import * as bt_host from 'bt_host' function onConnect() { // onConnect console.log('bt_host onConnect'); } function onDisconnect() { // onDisconnect console.log('bt_host onDisconnect'); app_start_adv(); } function app_add_service() { let service = { service: "{\ \"s_uuid\":\"0x1A1A\",\ ...
YifuLiu/AliOS-Things
components/amp/example-js/common/bt_host.js
JavaScript
apache-2.0
2,597
var network = require('network'); var netinfo = network.openNetWorkClient(); /** 获取网络类型 * 目前支持两种类型:wifi cellular(蜂窝网) */ var type = netinfo.getType(); console.log('net type is: ' + type); /** 获取网络状态 * 目前支持两种状态:connect disconnect(蜂窝网) */ var status = netinfo.getStatus(); console.log('net status is: ' + status); var...
YifuLiu/AliOS-Things
components/amp/example-js/common/cellular.js
JavaScript
apache-2.0
1,082
import * as checksum from 'checksum' import * as crypto from 'crypto' function crypto_test() { let enc_param = { 'key': '000102030405060708090a0b0c0d0e0f', 'in': '3132333435363738' } let enc_result = crypto.encrypt(enc_param); console.log('encrypt:'+enc_result) let dec_param = { 'key': '000102030405060...
YifuLiu/AliOS-Things
components/amp/example-js/common/crypto.js
JavaScript
apache-2.0
817
var dac = require('dac'); // led灯 var vol = dac.open({ id: 'light', success: function() { console.log('open dac success') }, fail: function() { console.log('open dac failed') } }); vol.writeValue(65536 / 2) var value = vol.readValue(); console.log('voltage value is ' + value) vol.close();
YifuLiu/AliOS-Things
components/amp/example-js/common/dac.js
JavaScript
apache-2.0
314
var event = require('events'); // console.log(event) var uartInstance = new event.EventEmitter(); uartInstance.on('data', function(arg, arg2) { console.log('uart event: ', arg, arg2); }) setInterval(function() { uartInstance.emit('data', 'this is uart data', 'data 2'); }, 1000);
YifuLiu/AliOS-Things
components/amp/example-js/common/events.js
JavaScript
apache-2.0
292
var fs = require('fs'); var path = './test.data'; var file_content = 'this is amp fs test file'; // write file fs.writeSync(path, file_content); // read file var data = fs.readSync(path); console.log('fs read: ' + data); fs.unlinkSync(path);
YifuLiu/AliOS-Things
components/amp/example-js/common/fs.js
JavaScript
apache-2.0
245
// import * as iot from 'iot' import * as iot from 'gateway' var productKey = 'a17rAb1ltpS'; var deviceName = '123454'; var deviceSecret = 'abf0028f3d7ccf2b9c555826f32381d8'; var lightSwitch = 0; var gateway; var subdev = [ { productKey: 'a1zK6eTWoZO', deviceName: 'test101', deviceSecret:...
YifuLiu/AliOS-Things
components/amp/example-js/common/gateway.js
JavaScript
apache-2.0
2,743
var gpio = require('gpio'); var led = gpio.open({ id: 'led', success: function() { console.log('gpio: open led success') }, fail: function() { console.log('gpio: open led failed') } }); var key = gpio.open({ id: 'key', success: function() { console.log('gpio: open key success') }, ...
YifuLiu/AliOS-Things
components/amp/example-js/common/gpio.js
JavaScript
apache-2.0
713
console.log('http: testing http...'); var http = require('http'); if (!(http && http.request)) { throw new Error("http: [failed] require(\'http\')"); } console.log('http: [success] require(\'http\')'); // request GET example var request_url = 'http://appengine.oss-cn-hangzhou.aliyuncs.com/httpTest.txt'; var def...
YifuLiu/AliOS-Things
components/amp/example-js/common/http.js
JavaScript
apache-2.0
1,397
var i2c = require('i2c'); var memaddr = 0x18 var msgbuf = [0x10, 0xee] // led灯 var sensor = i2c.open({ id: 'sensor', success: function() { console.log('open i2c success') }, fail: function() { console.log('open i2c failed') } }); sensor.write(msgbuf) var value = sensor.read(2) console.log('sensor v...
YifuLiu/AliOS-Things
components/amp/example-js/common/i2c.js
JavaScript
apache-2.0
476
import * as iot from 'iot' var productKey = 'a1MOapE3PH8'; /* your productKey */ var deviceName = 'FjWNmTsPWfPSykfkBv1l'; /* your deviceName */ var deviceSecret = '2a6afba08a135efda3c49e4cc7684254'; /* your deviceSecret */ var device ; var topic = '/sys/' + productKey + '/' + deviceName + '/user/haas/info'...
YifuLiu/AliOS-Things
components/amp/example-js/common/iot.js
JavaScript
apache-2.0
2,092
var mqtt = require('mqtt'); function ArrayToString(fileData) { var dataString = ""; for (var i = 0; i < fileData.length; i++) { dataString += String.fromCharCode(fileData[i]); } return dataString; } function onConnect() { // subscribe mqttClient.subscribe({ topic: '/hello', ...
YifuLiu/AliOS-Things
components/amp/example-js/common/mqtt.js
JavaScript
apache-2.0
1,187
var appota = require('appota'); var iot = require('iot'); /* device info */ var productKey = ''; /* your productKey */ var deviceName = ''; /* your deviceName */ var deviceSecret = ''; /* your deviceSecret */ var module_name = 'default'; var default_ver = '1.0.0'; var ota; var status; /* download info */ v...
YifuLiu/AliOS-Things
components/amp/example-js/common/ota.js
JavaScript
apache-2.0
2,258
console.log(Promise); function test_setTimeout() { return new Promise(function (resolve, reject) { console.log('=================setTimeout'); setTimeout(function () { console.log('=================setTimeout---------------done'); resolve(""); }, 1000); }); } fu...
YifuLiu/AliOS-Things
components/amp/example-js/common/promise.js
JavaScript
apache-2.0
794