├── .gitignore ├── README.md ├── _config.yml ├── analog_pulse ├── README.md ├── analog_pulse.js └── analog_pulse.txt ├── analog_read ├── README.md ├── analog_read.fzz ├── analog_read.js ├── analog_read.png └── analog_read.txt ├── analog_read_voltage ├── README.md ├── analog_read_voltage.fzz ├── analog_read_voltage.js ├── analog_read_voltage.png └── analog_read_voltage.txt ├── analog_read_watch ├── README.md ├── analog_read_watch.fzz ├── analog_read_watch.js ├── analog_read_watch.png └── analog_read_watch.txt ├── arduino_style_analog_read ├── README.md ├── arduino_style_analog_read.fzz ├── arduino_style_analog_read.js ├── arduino_style_analog_read.png └── arduino_style_analog_read.txt ├── arduino_style_bare_minimum ├── README.md └── arduino_style_bare_minimum.js ├── ascii_characters_list ├── README.md ├── ascii_characters_list.js └── ascii_characters_list.txt ├── ascii_characters_table ├── README.md ├── ascii_characters_table.js └── ascii_characters_table.txt ├── bare_minimum ├── README.md └── bare_minimum.js ├── board_info ├── README.md ├── board_info.js └── board_info.txt ├── decision_maker ├── README.md └── decision_maker.js ├── digital_multiple_read ├── README.md ├── digital_multiple_read.js └── digital_multiple_read.txt ├── digital_read ├── README.md ├── digital_read.js └── digital_read.txt ├── docs ├── favicon.ico ├── index.html ├── masonry.pkgd.min.js └── styles.css ├── extended_array_object ├── README.md ├── extended_array_object.js └── extended_array_object.txt ├── extended_math_object ├── README.md ├── extended_math_object.js └── extended_math_object.txt ├── extended_string_object ├── README.md ├── extended_string_object.js └── extended_string_object.txt ├── infinitive_save ├── README.md ├── infinitive_save.js └── infinitive_save.txt ├── license.txt ├── list_pins_with_modes ├── README.md ├── list_pins_with_modes.js └── list_pins_with_modes.txt ├── memory_hex_dump ├── README.md ├── memory_hex_dump.js └── memory_hex_dump.txt ├── memory_leak ├── README.md ├── memory_leak.js └── memory_leak.txt ├── morse_pulse_to_letter ├── README.md ├── morse_pulse_to_letter.js └── morse_pulse_to_letter.txt ├── on_board_led_blinker_1 ├── README.md └── on_board_led_blinker_1.js ├── on_board_led_blinker_10 ├── README.md └── on_board_led_blinker_10.js ├── on_board_led_blinker_11 ├── README.md └── on_board_led_blinker_11.js ├── on_board_led_blinker_12 ├── README.md └── on_board_led_blinker_12.js ├── on_board_led_blinker_2 ├── README.md └── on_board_led_blinker_2.js ├── on_board_led_blinker_3 ├── README.md └── on_board_led_blinker_3.js ├── on_board_led_blinker_4 ├── README.md └── on_board_led_blinker_4.js ├── on_board_led_blinker_5 ├── README.md └── on_board_led_blinker_5.js ├── on_board_led_blinker_6 ├── README.md └── on_board_led_blinker_6.js ├── on_board_led_blinker_7 ├── README.md └── on_board_led_blinker_7.js ├── on_board_led_blinker_8 ├── README.md └── on_board_led_blinker_8.js ├── on_board_led_blinker_9 ├── README.md └── on_board_led_blinker_9.js ├── play_a_melody ├── README.md ├── play_a_melody.fzz ├── play_a_melody.js └── play_a_melody.png ├── print_function_test ├── README.md ├── print_function_test.js └── print_function_test.txt ├── reflex_game ├── README.md ├── reflex_game.js └── reflex_game.txt ├── scripts ├── README-FOOTER.md ├── README-HEADER.md ├── copyright-notice.txt ├── generateRootReadme.sh ├── generateSubReadme.sh └── updateCopyrightNotice.sh ├── servo-object ├── README.md ├── servo-object.js └── servo-object.txt ├── text_to_morse_audio_1 ├── README.md ├── text_to_morse_audio_1.fzz ├── text_to_morse_audio_1.js ├── text_to_morse_audio_1.png └── text_to_morse_audio_1.txt ├── text_to_morse_audio_2 ├── README.md ├── text_to_morse_audio_2.fzz ├── text_to_morse_audio_2.js ├── text_to_morse_audio_2.png └── text_to_morse_audio_2.txt ├── toggle_button_object ├── README.md └── toggle_button_object.js └── xor_string ├── README.md ├── xor_string.js └── xor_string.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # JDeveloper 2 | classes/ 3 | .data/ 4 | .adf/ 5 | 6 | # SVN 7 | .svn 8 | 9 | # Linux 10 | *~ 11 | 12 | # Java 13 | *.class 14 | 15 | # OSX 16 | .DS_Store 17 | .AppleDouble 18 | .LSOverride 19 | 20 | # Icon must ends with two \r. 21 | Icon 22 | 23 | 24 | # Thumbnails 25 | ._* 26 | 27 | # Files that might appear on external disk 28 | .Spotlight-V100 29 | .Trashes 30 | .fseventsd 31 | .Trash-1000 32 | 33 | # Windows image file caches 34 | Thumbs.db 35 | ehthumbs.db 36 | 37 | # Folder config file 38 | Desktop.ini 39 | 40 | # Recycle Bin used on file shares 41 | $RECYCLE.BIN/ 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Espruino by Examples 2 | 3 | 4 | ## Examples by variables and functions 5 | 6 | * **variable HIGH** 7 | * [Reflex Game](./reflex_game) 8 | 9 | * **variable LOW** 10 | * [Reflex Game](./reflex_game) 11 | 12 | * **function analogRead(pin)** 13 | * [Analog Read](./analog_read) 14 | * [Analog Read Voltage](./analog_read_voltage) 15 | * [Analog Read Watch](./analog_read_watch) 16 | * [Arduino Style Analog Read](./arduino_style_analog_read) 17 | * [Servo Object](./servo-object) 18 | 19 | * **function analogWrite(pin, value, options)** 20 | * [Analog Pulse](./analog_pulse) 21 | * [Play a Melody For Espruino](./play_a_melody) 22 | * [Text to Morse Audio 1](./text_to_morse_audio_1) 23 | * [Text to Morse Audio 2](./text_to_morse_audio_2) 24 | 25 | * **function changeInterval(id, time)** 26 | * [Analog Read Watch](./analog_read_watch) 27 | 28 | * **function clearInterval(id)** 29 | * [Analog Read Watch](./analog_read_watch) 30 | * [Reflex Game](./reflex_game) 31 | * [Servo Object](./servo-object) 32 | 33 | * **function clearTimeout(id)** 34 | * [Decision Maker](./decision_maker) 35 | * [Morse Pulse to Letter](./morse_pulse_to_letter) 36 | 37 | * **function clearWatch(id)** 38 | * [Reflex Game](./reflex_game) 39 | * [Toggle Button Object](./toggle_button_object) 40 | 41 | * **function digitalPulse(pin, value, time)** 42 | * [On Board LED Blinker 3](./on_board_led_blinker_3) 43 | * [Servo Object](./servo-object) 44 | 45 | * **function digitalRead(pin)** 46 | * [Digital Multiple Read](./digital_multiple_read) 47 | * [Digital Read Example](./digital_read) 48 | * [On Board LED Blinker 11](./on_board_led_blinker_11) 49 | * [On Board LED Blinker 4](./on_board_led_blinker_4) 50 | 51 | * **function digitalWrite(pin, value)** 52 | * [Analog Pulse](./analog_pulse) 53 | * [On Board LED Blinker 1](./on_board_led_blinker_1) 54 | * [On Board LED Blinker 10](./on_board_led_blinker_10) 55 | * [On Board LED Blinker 11](./on_board_led_blinker_11) 56 | * [On Board LED Blinker 12](./on_board_led_blinker_12) 57 | * [On Board LED Blinker 2](./on_board_led_blinker_2) 58 | * [On Board LED Blinker 4](./on_board_led_blinker_4) 59 | * [On Board LED Blinker 6](./on_board_led_blinker_6) 60 | * [On Board LED Blinker 7](./on_board_led_blinker_7) 61 | * [On Board LED Blinker 8](./on_board_led_blinker_8) 62 | * [On Board LED Blinker 9](./on_board_led_blinker_9) 63 | * [Play a Melody For Espruino](./play_a_melody) 64 | * [Text to Morse Audio 1](./text_to_morse_audio_1) 65 | * [Text to Morse Audio 2](./text_to_morse_audio_2) 66 | * [Toggle Button Object](./toggle_button_object) 67 | 68 | * **function getPinMode(pin)** 69 | * [List Pins with Modes](./list_pins_with_modes) 70 | 71 | * **function getTime()** 72 | * [Analog Read Watch](./analog_read_watch) 73 | 74 | * **function peek8(addr)** 75 | * [Memory Hex Dump ](./memory_hex_dump) 76 | 77 | * **function print(text, ...)** 78 | * [Analog Pulse](./analog_pulse) 79 | * [Analog Read](./analog_read) 80 | * [Analog Read Voltage](./analog_read_voltage) 81 | * [Analog Read Watch](./analog_read_watch) 82 | * [Arduino Style Analog Read](./arduino_style_analog_read) 83 | * [ASCII Characters List](./ascii_characters_list) 84 | * [ASCII Characters Table](./ascii_characters_table) 85 | * [Board Info](./board_info) 86 | * [Digital Multiple Read](./digital_multiple_read) 87 | * [Digital Read Example](./digital_read) 88 | * [Extended Array Object](./extended_array_object) 89 | * [Extended Math Object](./extended_math_object) 90 | * [Extended Array Object](./extended_string_object) 91 | * [List Pins with Modes](./list_pins_with_modes) 92 | * [Memory Hex Dump ](./memory_hex_dump) 93 | * [Memory Leak](./memory_leak) 94 | * [Morse Pulse to Letter](./morse_pulse_to_letter) 95 | * [Print Function Test](./print_function_test) 96 | * [Reflex Game](./reflex_game) 97 | * [Servo Object](./servo-object) 98 | * [Text to Morse Audio 1](./text_to_morse_audio_1) 99 | * [Text to Morse Audio 2](./text_to_morse_audio_2) 100 | * [Toggle Button Object](./toggle_button_object) 101 | * [XOR String](./xor_string) 102 | 103 | * **function reset()** 104 | * [On Board LED Blinker 5](./on_board_led_blinker_5) 105 | * [Reflex Game](./reflex_game) 106 | 107 | * **function save()** 108 | * [Infinitive Save](./infinitive_save) 109 | 110 | * **function setInterval(function, timeout)** 111 | * [Analog Read Watch](./analog_read_watch) 112 | * [Arduino Style Bare Minimum](./arduino_style_bare_minimum) 113 | * [Memory Leak](./memory_leak) 114 | * [On Board LED Blinker 1](./on_board_led_blinker_1) 115 | * [On Board LED Blinker 10](./on_board_led_blinker_10) 116 | * [On Board LED Blinker 11](./on_board_led_blinker_11) 117 | * [On Board LED Blinker 12](./on_board_led_blinker_12) 118 | * [On Board LED Blinker 2](./on_board_led_blinker_2) 119 | * [On Board LED Blinker 3](./on_board_led_blinker_3) 120 | * [On Board LED Blinker 4](./on_board_led_blinker_4) 121 | * [On Board LED Blinker 5](./on_board_led_blinker_5) 122 | * [On Board LED Blinker 6](./on_board_led_blinker_6) 123 | * [On Board LED Blinker 7](./on_board_led_blinker_7) 124 | * [On Board LED Blinker 8](./on_board_led_blinker_8) 125 | * [On Board LED Blinker 9](./on_board_led_blinker_9) 126 | * [Reflex Game](./reflex_game) 127 | * [Servo Object](./servo-object) 128 | 129 | * **function setTimeout(function, timeout)** 130 | * [Analog Pulse](./analog_pulse) 131 | * [Decision Maker](./decision_maker) 132 | * [Morse Pulse to Letter](./morse_pulse_to_letter) 133 | * [Play a Melody For Espruino](./play_a_melody) 134 | * [Text to Morse Audio 1](./text_to_morse_audio_1) 135 | * [Text to Morse Audio 2](./text_to_morse_audio_2) 136 | 137 | * **function setWatch(function, pin, options)** 138 | * [Decision Maker](./decision_maker) 139 | * [Morse Pulse to Letter](./morse_pulse_to_letter) 140 | * [Reflex Game](./reflex_game) 141 | * [Toggle Button Object](./toggle_button_object) 142 | 143 | ## Bug tracker 144 | 145 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 146 | 147 | ## Twitter account 148 | 149 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 150 | 151 | ## Contributing 152 | 153 | 1. Fork it. 154 | 2. Create a branch (`git checkout -b myEspruino`) 155 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 156 | 4. Push to the branch (`git push origin myEspruino`) 157 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 158 | 159 | ## License 160 | 161 | Espruino by Examples < http://git.io/ebe > 162 | 163 | Copyright (c) 2014-2021 Anar Software LLC. < http://anars.com > 164 | 165 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 166 | 167 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 168 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-tactile -------------------------------------------------------------------------------- /analog_pulse/README.md: -------------------------------------------------------------------------------- 1 | # Analog Pulse 2 | 3 | **by Kay Anar in July 20, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | =undefined 15 | End of the pulse! 16 | > 17 | ```` 18 | 19 | 20 | ## Bug tracker 21 | 22 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 23 | 24 | ## Twitter account 25 | 26 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 27 | 28 | ## Contributing 29 | 30 | 1. Fork it. 31 | 2. Create a branch (`git checkout -b myEspruino`) 32 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 33 | 4. Push to the branch (`git push origin myEspruino`) 34 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 35 | 36 | ## License 37 | 38 | Espruino by Examples < http://git.io/ebe > 39 | 40 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 41 | 42 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 43 | 44 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 45 | 46 | 47 | -------------------------------------------------------------------------------- /analog_pulse/analog_pulse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Analog Pulse 21 | by Kay Anar in July 20, 2014 22 | 23 | Pulse the pin with the analog value for the given time in milliseconds. 24 | 25 | Parameters : 26 | pin - The pin to use 27 | value - A value between 0.0 and 1.0 28 | time - A time in milliseconds 29 | Options Parameters : 30 | freq - pulse frequency in Hz (optional) 31 | func - function to be executed when end of the pulse (optional) 32 | 33 | */ 34 | 35 | function analogPulse(pin, value, time, options) 36 | { 37 | analogWrite(pin, value, options ); 38 | setTimeout(function() { digitalWrite(pin, 0); try { options["func"](); } catch(e){ } }, time); 39 | } 40 | 41 | analogPulse(A10, 0.5, 1000, { freq: 500, func: function() { print("End of the pulse!"); } }); -------------------------------------------------------------------------------- /analog_pulse/analog_pulse.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | =undefined 9 | End of the pulse! 10 | > -------------------------------------------------------------------------------- /analog_read/README.md: -------------------------------------------------------------------------------- 1 | # Analog Read 2 | 3 | **by Kay Anar in July 14, 2014 ** 4 | 5 | ## Board Setup 6 | ![Board Setup](analog_read.png "Board Setup for Analog Read") 7 | 8 | 9 | ## Sample Output 10 | ```` 11 | _____ _ 12 | | __|___ ___ ___ _ _|_|___ ___ 13 | | __|_ -| . | _| | | | | . | 14 | |_____|___| _|_| |___|_|_|_|___| 15 | |_| http://espruino.com 16 | 1v67 Copyright 2014 G.Williams 17 | >echo(0); 18 | Value = 0.76295109483 19 | =undefined 20 | > 21 | ```` 22 | 23 | 24 | ## Bug tracker 25 | 26 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 27 | 28 | ## Twitter account 29 | 30 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 31 | 32 | ## Contributing 33 | 34 | 1. Fork it. 35 | 2. Create a branch (`git checkout -b myEspruino`) 36 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 37 | 4. Push to the branch (`git push origin myEspruino`) 38 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 39 | 40 | ## License 41 | 42 | Espruino by Examples < http://git.io/ebe > 43 | 44 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 45 | 46 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 47 | 48 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 49 | 50 | 51 | -------------------------------------------------------------------------------- /analog_read/analog_read.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/analog_read/analog_read.fzz -------------------------------------------------------------------------------- /analog_read/analog_read.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Analog Read 21 | by Kay Anar in July 14, 2014 22 | 23 | */ 24 | 25 | var PIN = C4; 26 | 27 | function onInit() 28 | { 29 | // read the pin's analog value 30 | var pinValue = analogRead(PIN); 31 | 32 | // print out the value you read 33 | print("Value", "=", pinValue); 34 | } 35 | 36 | // call the onInit() function 37 | onInit(); -------------------------------------------------------------------------------- /analog_read/analog_read.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/analog_read/analog_read.png -------------------------------------------------------------------------------- /analog_read/analog_read.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Value = 0.76295109483 9 | =undefined 10 | > -------------------------------------------------------------------------------- /analog_read_voltage/README.md: -------------------------------------------------------------------------------- 1 | # Analog Read Voltage 2 | 3 | **by Kay Anar on July 14, 2014** 4 | 5 | ## Board Setup 6 | ![Board Setup](analog_read_voltage.png "Board Setup for Analog Read Voltage") 7 | 8 | 9 | ## Sample Output 10 | ```` 11 | _____ _ 12 | | __|___ ___ ___ _ _|_|___ ___ 13 | | __|_ -| . | _| | | | | . | 14 | |_____|___| _|_| |___|_|_|_|___| 15 | |_| http://espruino.com 16 | 1v67 Copyright 2014 G.Williams 17 | >echo(0); 18 | Value = 2.47148594377 Volts 19 | =undefined 20 | > 21 | ```` 22 | 23 | 24 | ## Bug tracker 25 | 26 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 27 | 28 | ## Twitter account 29 | 30 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 31 | 32 | ## Contributing 33 | 34 | 1. Fork it. 35 | 2. Create a branch (`git checkout -b myEspruino`) 36 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 37 | 4. Push to the branch (`git push origin myEspruino`) 38 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 39 | 40 | ## License 41 | 42 | Espruino by Examples < http://git.io/ebe > 43 | 44 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 45 | 46 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 47 | 48 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 49 | 50 | 51 | -------------------------------------------------------------------------------- /analog_read_voltage/analog_read_voltage.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/analog_read_voltage/analog_read_voltage.fzz -------------------------------------------------------------------------------- /analog_read_voltage/analog_read_voltage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Analog Read Voltage 21 | by Kay Anar on July 14, 2014 22 | 23 | */ 24 | 25 | var PIN = C4; 26 | 27 | function onInit() 28 | { 29 | // read the pin's analog value 30 | var pinValue = analogRead(PIN) * E.getAnalogVRef(); 31 | 32 | // print out the value you read 33 | print("Value", "=", pinValue, "Volts"); 34 | } 35 | 36 | // call the onInit() function 37 | onInit(); -------------------------------------------------------------------------------- /analog_read_voltage/analog_read_voltage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/analog_read_voltage/analog_read_voltage.png -------------------------------------------------------------------------------- /analog_read_voltage/analog_read_voltage.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Value = 2.47148594377 Volts 9 | =undefined 10 | > -------------------------------------------------------------------------------- /analog_read_watch/README.md: -------------------------------------------------------------------------------- 1 | # Analog Read Watch 2 | 3 | **by Kay Anar in July 14, 2014** 4 | 5 | ## Board Setup 6 | ![Board Setup](analog_read_watch.png "Board Setup for Analog Read Watch") 7 | 8 | 9 | ## Sample Output 10 | ```` 11 | _____ _ 12 | | __|___ ___ ___ _ _|_|___ ___ 13 | | __|_ -| . | _| | | | | . | 14 | |_____|___| _|_| |___|_|_|_|___| 15 | |_| http://espruino.com 16 | 1v67 Copyright 2014 G.Williams 17 | >echo(0); 18 | =undefined 19 | {"value":0.77979705500,"valueAs7Bit":798,"valueAsVolt":2.56546184738,"lastValue":0.76636911573,"lastValueAs7Bit":784,"lastValueAsVolt":2.52466487935,"time":423.92601108551,"lastTime":422.95424556732} 20 | {"value":0.75172045471,"valueAs7Bit":769,"valueAsVolt":2.47474882786,"lastValue":0.77979705500,"lastValueAs7Bit":798,"lastValueAsVolt":2.56890080428,"time":424.89333152770,"lastTime":423.92601108551} 21 | {"value":0.79078355077,"valueAs7Bit":809,"valueAsVolt":2.60334896182,"lastValue":0.75172045471,"lastValueAs7Bit":769,"lastValueAsVolt":2.47640750670,"time":426.82769489288,"lastTime":424.89333152770} 22 | {"value":0.76148622873,"valueAs7Bit":779,"valueAsVolt":2.50522088353,"lastValue":0.79078355077,"lastValueAs7Bit":809,"lastValueAsVolt":2.60684104627,"time":427.79498386383,"lastTime":426.82769489288} 23 | {"value":0.79053940642,"valueAs7Bit":809,"valueAsVolt":2.60254521098,"lastValue":0.76148622873,"lastValueAs7Bit":779,"lastValueAsVolt":2.50857908847,"time":429.72944450378,"lastTime":427.79498386383} 24 | {"value":0.75513847562,"valueAs7Bit":773,"valueAsVolt":2.48433734939,"lastValue":0.79053940642,"lastValueAs7Bit":809,"lastValueAsVolt":2.60254521098,"time":430.69681167602,"lastTime":429.72944450378} 25 | {"value":0.77418173495,"valueAs7Bit":792,"valueAsVolt":2.54698795180,"lastValue":0.75513847562,"lastValueAs7Bit":773,"lastValueAsVolt":2.48600133958,"time":432.63117313385,"lastTime":430.69681167602} 26 | {"value":0.74073395895,"valueAs7Bit":758,"valueAsVolt":2.43694779116,"lastValue":0.77418173495,"lastValueAs7Bit":792,"lastValueAsVolt":2.54869390488,"time":433.59840679168,"lastTime":432.63117313385} 27 | {"value":0.76612497138,"valueAs7Bit":784,"valueAsVolt":2.52048192771,"lastValue":0.74073395895,"lastValueAs7Bit":758,"lastValueAsVolt":2.43858004018,"time":435.53292369842,"lastTime":433.59840679168} 28 | {"value":0.74000152590,"valueAs7Bit":757,"valueAsVolt":2.43290969899,"lastValue":0.76612497138,"lastValueAs7Bit":784,"lastValueAsVolt":2.52217012726,"time":436.50025177001,"lastTime":435.53292369842} 29 | {"value":0.77711146715,"valueAs7Bit":795,"valueAsVolt":2.55491638795,"lastValue":0.74000152590,"lastValueAs7Bit":757,"lastValueAsVolt":2.43616878767,"time":438.43457317352,"lastTime":436.50025177001} 30 | {"value":0.75367360952,"valueAs7Bit":771,"valueAsVolt":2.48450704225,"lastValue":0.77711146715,"lastValueAs7Bit":795,"lastValueAsVolt":2.55833891493,"time":439.40185451507,"lastTime":438.43457317352} 31 | > 32 | ```` 33 | 34 | 35 | ## Bug tracker 36 | 37 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 38 | 39 | ## Twitter account 40 | 41 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 42 | 43 | ## Contributing 44 | 45 | 1. Fork it. 46 | 2. Create a branch (`git checkout -b myEspruino`) 47 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 48 | 4. Push to the branch (`git push origin myEspruino`) 49 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 50 | 51 | ## License 52 | 53 | Espruino by Examples < http://git.io/ebe > 54 | 55 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 56 | 57 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 58 | 59 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 60 | 61 | 62 | -------------------------------------------------------------------------------- /analog_read_watch/analog_read_watch.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/analog_read_watch/analog_read_watch.fzz -------------------------------------------------------------------------------- /analog_read_watch/analog_read_watch.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Analog Read Watch 21 | by Kay Anar in July 14, 2014 22 | 23 | */ 24 | var AnalogReadWatch = function(watchPin, eventFunction, timeout, difference, repeat) 25 | { 26 | if (typeof watchPin != "number") 27 | { 28 | print("ERROR: Unknown watchPin"); 29 | return; 30 | } 31 | 32 | if (typeof difference != "number") 33 | difference = 0.01; 34 | 35 | this.getDifference = function() 36 | { 37 | return(difference); 38 | }; 39 | 40 | this.setDifference = function(newDifference) 41 | { 42 | if (typeof newDifference == "number") 43 | difference = newDifference; 44 | }; 45 | 46 | if (typeof repeat != "boolean") 47 | repeat = true; 48 | 49 | this.getRepeat = function() 50 | { 51 | return(repeat); 52 | }; 53 | 54 | this.setRepeat = function(newRepeat) 55 | { 56 | if (typeof newRepeat == "boolean") 57 | repeat = newRepeat; 58 | }; 59 | 60 | var _lastValue = analogRead(watchPin); 61 | 62 | this.getLastValue = function() 63 | { 64 | return(_lastValue); 65 | }; 66 | 67 | this.getLastValueAs7Bit = function() 68 | { 69 | return(_lastValue * 1024 | 0); 70 | }; 71 | 72 | this.getLastValueAsVolt = function() 73 | { 74 | return(_lastValue * E.getAnalogVRef()); 75 | }; 76 | 77 | var _lastTime = getTime(); 78 | 79 | this.getLastTime = function() 80 | { 81 | return(_lastTime); 82 | }; 83 | 84 | if (typeof timeout != "number") 85 | timeout = 1000; 86 | 87 | this.getTimeout = function() 88 | { 89 | return(timeout); 90 | }; 91 | 92 | this.setCheckInterval = function(newTimeout) 93 | { 94 | if (typeof timeout == "number") 95 | { 96 | timeout = newTimeout; 97 | if (_interval != -1) 98 | changeInterval(_interval, timeout); 99 | } 100 | }; 101 | 102 | var checkPinValue = function() 103 | { 104 | var value = analogRead(watchPin); 105 | if (Math.abs(_lastValue - value) >= difference) 106 | { 107 | var time = getTime(); 108 | if (typeof eventFunction == "function") 109 | eventFunction( 110 | { 111 | "value" : value, 112 | "valueAs7Bit" : value * 1024 | 0, 113 | "valueAsVolt" : value * E.getAnalogVRef(), 114 | "lastValue" : _lastValue, 115 | "lastValueAs7Bit" : _lastValue * 1024 | 0, 116 | "lastValueAsVolt" : _lastValue * E.getAnalogVRef(), 117 | "time" : time, 118 | "lastTime" : _lastTime 119 | }); 120 | _lastValue = value; 121 | _lastTime = time; 122 | if (!repeat) 123 | clearInterval(_interval); 124 | } 125 | }; 126 | 127 | var _interval = setInterval(checkPinValue, timeout); 128 | 129 | this.start = function() 130 | { 131 | if (_interval == -1) 132 | _interval = setInterval(checkPinValue, timeout); 133 | }; 134 | 135 | this.stop = function() 136 | { 137 | clearInterval(_interval); 138 | _interval = -1; 139 | }; 140 | 141 | this.isRunning = function() 142 | { 143 | return(_interval != -1); 144 | }; 145 | }; 146 | 147 | var wObj = new AnalogReadWatch(C4, function(data) { print(data); }, 1000, 0.01, true ); -------------------------------------------------------------------------------- /analog_read_watch/analog_read_watch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/analog_read_watch/analog_read_watch.png -------------------------------------------------------------------------------- /analog_read_watch/analog_read_watch.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | =undefined 9 | {"value":0.77979705500,"valueAs7Bit":798,"valueAsVolt":2.56546184738,"lastValue":0.76636911573,"lastValueAs7Bit":784,"lastValueAsVolt":2.52466487935,"time":423.92601108551,"lastTime":422.95424556732} 10 | {"value":0.75172045471,"valueAs7Bit":769,"valueAsVolt":2.47474882786,"lastValue":0.77979705500,"lastValueAs7Bit":798,"lastValueAsVolt":2.56890080428,"time":424.89333152770,"lastTime":423.92601108551} 11 | {"value":0.79078355077,"valueAs7Bit":809,"valueAsVolt":2.60334896182,"lastValue":0.75172045471,"lastValueAs7Bit":769,"lastValueAsVolt":2.47640750670,"time":426.82769489288,"lastTime":424.89333152770} 12 | {"value":0.76148622873,"valueAs7Bit":779,"valueAsVolt":2.50522088353,"lastValue":0.79078355077,"lastValueAs7Bit":809,"lastValueAsVolt":2.60684104627,"time":427.79498386383,"lastTime":426.82769489288} 13 | {"value":0.79053940642,"valueAs7Bit":809,"valueAsVolt":2.60254521098,"lastValue":0.76148622873,"lastValueAs7Bit":779,"lastValueAsVolt":2.50857908847,"time":429.72944450378,"lastTime":427.79498386383} 14 | {"value":0.75513847562,"valueAs7Bit":773,"valueAsVolt":2.48433734939,"lastValue":0.79053940642,"lastValueAs7Bit":809,"lastValueAsVolt":2.60254521098,"time":430.69681167602,"lastTime":429.72944450378} 15 | {"value":0.77418173495,"valueAs7Bit":792,"valueAsVolt":2.54698795180,"lastValue":0.75513847562,"lastValueAs7Bit":773,"lastValueAsVolt":2.48600133958,"time":432.63117313385,"lastTime":430.69681167602} 16 | {"value":0.74073395895,"valueAs7Bit":758,"valueAsVolt":2.43694779116,"lastValue":0.77418173495,"lastValueAs7Bit":792,"lastValueAsVolt":2.54869390488,"time":433.59840679168,"lastTime":432.63117313385} 17 | {"value":0.76612497138,"valueAs7Bit":784,"valueAsVolt":2.52048192771,"lastValue":0.74073395895,"lastValueAs7Bit":758,"lastValueAsVolt":2.43858004018,"time":435.53292369842,"lastTime":433.59840679168} 18 | {"value":0.74000152590,"valueAs7Bit":757,"valueAsVolt":2.43290969899,"lastValue":0.76612497138,"lastValueAs7Bit":784,"lastValueAsVolt":2.52217012726,"time":436.50025177001,"lastTime":435.53292369842} 19 | {"value":0.77711146715,"valueAs7Bit":795,"valueAsVolt":2.55491638795,"lastValue":0.74000152590,"lastValueAs7Bit":757,"lastValueAsVolt":2.43616878767,"time":438.43457317352,"lastTime":436.50025177001} 20 | {"value":0.75367360952,"valueAs7Bit":771,"valueAsVolt":2.48450704225,"lastValue":0.77711146715,"lastValueAs7Bit":795,"lastValueAsVolt":2.55833891493,"time":439.40185451507,"lastTime":438.43457317352} 21 | > -------------------------------------------------------------------------------- /arduino_style_analog_read/README.md: -------------------------------------------------------------------------------- 1 | # Arduino Style Analog Read 2 | 3 | **by Kay Anar in July 14, 2014** 4 | 5 | ## Board Setup 6 | ![Board Setup](arduino_style_analog_read.png "Board Setup for Arduino Style Analog Read") 7 | 8 | 9 | ## Sample Output 10 | ```` 11 | _____ _ 12 | | __|___ ___ ___ _ _|_|___ ___ 13 | | __|_ -| . | _| | | | | . | 14 | |_____|___| _|_| |___|_|_|_|___| 15 | |_| http://espruino.com 16 | 1v67 Copyright 2014 G.Williams 17 | >echo(0); 18 | Value = 779 Units ( 0.00321710908 Volts Per Unit ) 19 | =undefined 20 | > 21 | ```` 22 | 23 | 24 | ## Bug tracker 25 | 26 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 27 | 28 | ## Twitter account 29 | 30 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 31 | 32 | ## Contributing 33 | 34 | 1. Fork it. 35 | 2. Create a branch (`git checkout -b myEspruino`) 36 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 37 | 4. Push to the branch (`git push origin myEspruino`) 38 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 39 | 40 | ## License 41 | 42 | Espruino by Examples < http://git.io/ebe > 43 | 44 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 45 | 46 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 47 | 48 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 49 | 50 | 51 | -------------------------------------------------------------------------------- /arduino_style_analog_read/arduino_style_analog_read.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/arduino_style_analog_read/arduino_style_analog_read.fzz -------------------------------------------------------------------------------- /arduino_style_analog_read/arduino_style_analog_read.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Arduino Style Analog Read 21 | by Kay Anar in July 14, 2014 22 | 23 | */ 24 | 25 | var PIN = C4; 26 | 27 | function onInit() 28 | { 29 | // read the pin's analog value, converts it to Arduino value 30 | var pinValue = analogRead(PIN) * 1023 | 0; 31 | 32 | // print out the value you read 33 | print("Value", "=", pinValue, "Units", "(", E.getAnalogVRef() / 1024, "Volts Per Unit", ")"); 34 | } 35 | 36 | // call the onInit() function 37 | onInit(); -------------------------------------------------------------------------------- /arduino_style_analog_read/arduino_style_analog_read.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/arduino_style_analog_read/arduino_style_analog_read.png -------------------------------------------------------------------------------- /arduino_style_analog_read/arduino_style_analog_read.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Value = 779 Units ( 0.00321710908 Volts Per Unit ) 9 | =undefined 10 | > -------------------------------------------------------------------------------- /arduino_style_bare_minimum/README.md: -------------------------------------------------------------------------------- 1 | # Arduino Style Bare Minimum 2 | 3 | **by Kay Anar in July 14, 2014 ** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /arduino_style_bare_minimum/arduino_style_bare_minimum.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Arduino Style Bare Minimum 21 | by Kay Anar in July 14, 2014 22 | 23 | */ 24 | 25 | function onInit() 26 | { 27 | // put your setup code here, to run once 28 | } 29 | 30 | function loop() 31 | { 32 | // do repeated stuff here 33 | } 34 | 35 | // call the onInit() function 36 | onInit(); 37 | 38 | // call the loop function every 10 ms 39 | setInterval(loop, 10); -------------------------------------------------------------------------------- /ascii_characters_list/ascii_characters_list.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | ASCII Characters List 21 | by Kay Anar in July 6, 2014 22 | 23 | */ 24 | 25 | function padZero(value, digit) 26 | { 27 | var zeros = digit - value.length; 28 | for(var index = 0; index < zeros; index++) 29 | value = "0" + value; 30 | return(value); 31 | } 32 | 33 | function asciiList() 34 | { 35 | for(var index = 0; index < 256; index++) 36 | { 37 | if (index == 0) 38 | print("ASCII control characters (character code 0-31)"); 39 | else if (index == 32) 40 | print("ASCII printable characters (character code 32-127)"); 41 | else if (index == 128) 42 | print("The extended ASCII codes (character code 128-255)"); 43 | print("Dec :", padZero(""+ index, 3), " Oct :", padZero(index.toString(8), 3), " Hex :", padZero(index.toString(16).toUpperCase(), 2), " Asc :", String.fromCharCode(index)); 44 | } 45 | } 46 | 47 | function onInit() 48 | { 49 | asciiList(); 50 | } 51 | 52 | onInit(); -------------------------------------------------------------------------------- /ascii_characters_list/ascii_characters_list.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | ASCII control characters (character code 0-31) 9 | Dec : 000 Oct : 000 Hex : 00 Asc : 10 | Dec : 001 Oct : 001 Hex : 01 Asc :  11 | Dec : 002 Oct : 002 Hex : 02 Asc :  12 | Dec : 003 Oct : 003 Hex : 03 Asc :  13 | Dec : 004 Oct : 004 Hex : 04 Asc :  14 | Dec : 005 Oct : 005 Hex : 05 Asc :  15 | Dec : 006 Oct : 006 Hex : 06 Asc :  16 | Dec : 007 Oct : 007 Hex : 07 Asc :  17 | Dec : 008 Oct : 010 Hex : 08 Asc : 18 | Dec : 009 Oct : 011 Hex : 09 Asc : 19 | Dec : 010 Oct : 012 Hex : 0A Asc : 20 | Dec : 011 Oct : 013 Hex : 0B Asc : 21 | Dec : 012 Oct : 014 Hex : 0C Asc : 22 | Dec : 013 Oct : 015 Hex : 0D Asc : 23 | Dec : 014 Oct : 016 Hex : 0E Asc :  24 | Dec : 015 Oct : 017 Hex : 0F Asc :  25 | Dec : 016 Oct : 020 Hex : 10 Asc :  26 | Dec : 017 Oct : 021 Hex : 11 Asc :  27 | Dec : 018 Oct : 022 Hex : 12 Asc :  28 | Dec : 019 Oct : 023 Hex : 13 Asc :  29 | Dec : 020 Oct : 024 Hex : 14 Asc :  30 | Dec : 021 Oct : 025 Hex : 15 Asc :  31 | Dec : 022 Oct : 026 Hex : 16 Asc :  32 | Dec : 023 Oct : 027 Hex : 17 Asc :  33 | Dec : 024 Oct : 030 Hex : 18 Asc :  34 | Dec : 025 Oct : 031 Hex : 19 Asc :  35 | Dec : 026 Oct : 032 Hex : 1A Asc :  36 | Dec : 027 Oct : 033 Hex : 1B Asc : 37 | Dec : 028 Oct : 034 Hex : 1C Asc :  38 | Dec : 029 Oct : 035 Hex : 1D Asc :  39 | Dec : 030 Oct : 036 Hex : 1E Asc :  40 | Dec : 031 Oct : 037 Hex : 1F Asc :  41 | ASCII printable characters (character code 32-127) 42 | Dec : 032 Oct : 040 Hex : 20 Asc : 43 | Dec : 033 Oct : 041 Hex : 21 Asc : ! 44 | Dec : 034 Oct : 042 Hex : 22 Asc : " 45 | Dec : 035 Oct : 043 Hex : 23 Asc : # 46 | Dec : 036 Oct : 044 Hex : 24 Asc : $ 47 | Dec : 037 Oct : 045 Hex : 25 Asc : % 48 | Dec : 038 Oct : 046 Hex : 26 Asc : & 49 | Dec : 039 Oct : 047 Hex : 27 Asc : ' 50 | Dec : 040 Oct : 050 Hex : 28 Asc : ( 51 | Dec : 041 Oct : 051 Hex : 29 Asc : ) 52 | Dec : 042 Oct : 052 Hex : 2A Asc : * 53 | Dec : 043 Oct : 053 Hex : 2B Asc : + 54 | Dec : 044 Oct : 054 Hex : 2C Asc : , 55 | Dec : 045 Oct : 055 Hex : 2D Asc : - 56 | Dec : 046 Oct : 056 Hex : 2E Asc : . 57 | Dec : 047 Oct : 057 Hex : 2F Asc : / 58 | Dec : 048 Oct : 060 Hex : 30 Asc : 0 59 | Dec : 049 Oct : 061 Hex : 31 Asc : 1 60 | Dec : 050 Oct : 062 Hex : 32 Asc : 2 61 | Dec : 051 Oct : 063 Hex : 33 Asc : 3 62 | Dec : 052 Oct : 064 Hex : 34 Asc : 4 63 | Dec : 053 Oct : 065 Hex : 35 Asc : 5 64 | Dec : 054 Oct : 066 Hex : 36 Asc : 6 65 | Dec : 055 Oct : 067 Hex : 37 Asc : 7 66 | Dec : 056 Oct : 070 Hex : 38 Asc : 8 67 | Dec : 057 Oct : 071 Hex : 39 Asc : 9 68 | Dec : 058 Oct : 072 Hex : 3A Asc : : 69 | Dec : 059 Oct : 073 Hex : 3B Asc : ; 70 | Dec : 060 Oct : 074 Hex : 3C Asc : < 71 | Dec : 061 Oct : 075 Hex : 3D Asc : = 72 | Dec : 062 Oct : 076 Hex : 3E Asc : > 73 | Dec : 063 Oct : 077 Hex : 3F Asc : ? 74 | Dec : 064 Oct : 100 Hex : 40 Asc : @ 75 | Dec : 065 Oct : 101 Hex : 41 Asc : A 76 | Dec : 066 Oct : 102 Hex : 42 Asc : B 77 | Dec : 067 Oct : 103 Hex : 43 Asc : C 78 | Dec : 068 Oct : 104 Hex : 44 Asc : D 79 | Dec : 069 Oct : 105 Hex : 45 Asc : E 80 | Dec : 070 Oct : 106 Hex : 46 Asc : F 81 | Dec : 071 Oct : 107 Hex : 47 Asc : G 82 | Dec : 072 Oct : 110 Hex : 48 Asc : H 83 | Dec : 073 Oct : 111 Hex : 49 Asc : I 84 | Dec : 074 Oct : 112 Hex : 4A Asc : J 85 | Dec : 075 Oct : 113 Hex : 4B Asc : K 86 | Dec : 076 Oct : 114 Hex : 4C Asc : L 87 | Dec : 077 Oct : 115 Hex : 4D Asc : M 88 | Dec : 078 Oct : 116 Hex : 4E Asc : N 89 | Dec : 079 Oct : 117 Hex : 4F Asc : O 90 | Dec : 080 Oct : 120 Hex : 50 Asc : P 91 | Dec : 081 Oct : 121 Hex : 51 Asc : Q 92 | Dec : 082 Oct : 122 Hex : 52 Asc : R 93 | Dec : 083 Oct : 123 Hex : 53 Asc : S 94 | Dec : 084 Oct : 124 Hex : 54 Asc : T 95 | Dec : 085 Oct : 125 Hex : 55 Asc : U 96 | Dec : 086 Oct : 126 Hex : 56 Asc : V 97 | Dec : 087 Oct : 127 Hex : 57 Asc : W 98 | Dec : 088 Oct : 130 Hex : 58 Asc : X 99 | Dec : 089 Oct : 131 Hex : 59 Asc : Y 100 | Dec : 090 Oct : 132 Hex : 5A Asc : Z 101 | Dec : 091 Oct : 133 Hex : 5B Asc : [ 102 | Dec : 092 Oct : 134 Hex : 5C Asc : \ 103 | Dec : 093 Oct : 135 Hex : 5D Asc : ] 104 | Dec : 094 Oct : 136 Hex : 5E Asc : ^ 105 | Dec : 095 Oct : 137 Hex : 5F Asc : _ 106 | Dec : 096 Oct : 140 Hex : 60 Asc : ` 107 | Dec : 097 Oct : 141 Hex : 61 Asc : a 108 | Dec : 098 Oct : 142 Hex : 62 Asc : b 109 | Dec : 099 Oct : 143 Hex : 63 Asc : c 110 | Dec : 100 Oct : 144 Hex : 64 Asc : d 111 | Dec : 101 Oct : 145 Hex : 65 Asc : e 112 | Dec : 102 Oct : 146 Hex : 66 Asc : f 113 | Dec : 103 Oct : 147 Hex : 67 Asc : g 114 | Dec : 104 Oct : 150 Hex : 68 Asc : h 115 | Dec : 105 Oct : 151 Hex : 69 Asc : i 116 | Dec : 106 Oct : 152 Hex : 6A Asc : j 117 | Dec : 107 Oct : 153 Hex : 6B Asc : k 118 | Dec : 108 Oct : 154 Hex : 6C Asc : l 119 | Dec : 109 Oct : 155 Hex : 6D Asc : m 120 | Dec : 110 Oct : 156 Hex : 6E Asc : n 121 | Dec : 111 Oct : 157 Hex : 6F Asc : o 122 | Dec : 112 Oct : 160 Hex : 70 Asc : p 123 | Dec : 113 Oct : 161 Hex : 71 Asc : q 124 | Dec : 114 Oct : 162 Hex : 72 Asc : r 125 | Dec : 115 Oct : 163 Hex : 73 Asc : s 126 | Dec : 116 Oct : 164 Hex : 74 Asc : t 127 | Dec : 117 Oct : 165 Hex : 75 Asc : u 128 | Dec : 118 Oct : 166 Hex : 76 Asc : v 129 | Dec : 119 Oct : 167 Hex : 77 Asc : w 130 | Dec : 120 Oct : 170 Hex : 78 Asc : x 131 | Dec : 121 Oct : 171 Hex : 79 Asc : y 132 | Dec : 122 Oct : 172 Hex : 7A Asc : z 133 | Dec : 123 Oct : 173 Hex : 7B Asc : { 134 | Dec : 124 Oct : 174 Hex : 7C Asc : | 135 | Dec : 125 Oct : 175 Hex : 7D Asc : } 136 | Dec : 126 Oct : 176 Hex : 7E Asc : ~ 137 | Dec : 127 Oct : 177 Hex : 7F Asc :  138 | The extended ASCII codes (character code 128-255) 139 | Dec : 128 Oct : 200 Hex : 80 Asc : € 140 | Dec : 129 Oct : 201 Hex : 81 Asc :  141 | Dec : 130 Oct : 202 Hex : 82 Asc : ‚ 142 | Dec : 131 Oct : 203 Hex : 83 Asc : ƒ 143 | Dec : 132 Oct : 204 Hex : 84 Asc : „ 144 | Dec : 133 Oct : 205 Hex : 85 Asc : … 145 | Dec : 134 Oct : 206 Hex : 86 Asc : † 146 | Dec : 135 Oct : 207 Hex : 87 Asc : ‡ 147 | Dec : 136 Oct : 210 Hex : 88 Asc : ˆ 148 | Dec : 137 Oct : 211 Hex : 89 Asc : ‰ 149 | Dec : 138 Oct : 212 Hex : 8A Asc : Š 150 | Dec : 139 Oct : 213 Hex : 8B Asc : ‹ 151 | Dec : 140 Oct : 214 Hex : 8C Asc : Œ 152 | Dec : 141 Oct : 215 Hex : 8D Asc :  153 | Dec : 142 Oct : 216 Hex : 8E Asc : Ž 154 | Dec : 143 Oct : 217 Hex : 8F Asc :  155 | Dec : 144 Oct : 220 Hex : 90 Asc :  156 | Dec : 145 Oct : 221 Hex : 91 Asc : ‘ 157 | Dec : 146 Oct : 222 Hex : 92 Asc : ’ 158 | Dec : 147 Oct : 223 Hex : 93 Asc : “ 159 | Dec : 148 Oct : 224 Hex : 94 Asc : ” 160 | Dec : 149 Oct : 225 Hex : 95 Asc : • 161 | Dec : 150 Oct : 226 Hex : 96 Asc : – 162 | Dec : 151 Oct : 227 Hex : 97 Asc : — 163 | Dec : 152 Oct : 230 Hex : 98 Asc : ˜ 164 | Dec : 153 Oct : 231 Hex : 99 Asc : ™ 165 | Dec : 154 Oct : 232 Hex : 9A Asc : š 166 | Dec : 155 Oct : 233 Hex : 9B Asc : › 167 | Dec : 156 Oct : 234 Hex : 9C Asc : œ 168 | Dec : 157 Oct : 235 Hex : 9D Asc :  169 | Dec : 158 Oct : 236 Hex : 9E Asc : ž 170 | Dec : 159 Oct : 237 Hex : 9F Asc : Ÿ 171 | Dec : 160 Oct : 240 Hex : A0 Asc : 172 | Dec : 161 Oct : 241 Hex : A1 Asc : ¡ 173 | Dec : 162 Oct : 242 Hex : A2 Asc : ¢ 174 | Dec : 163 Oct : 243 Hex : A3 Asc : £ 175 | Dec : 164 Oct : 244 Hex : A4 Asc : ¤ 176 | Dec : 165 Oct : 245 Hex : A5 Asc : ¥ 177 | Dec : 166 Oct : 246 Hex : A6 Asc : ¦ 178 | Dec : 167 Oct : 247 Hex : A7 Asc : § 179 | Dec : 168 Oct : 250 Hex : A8 Asc : ¨ 180 | Dec : 169 Oct : 251 Hex : A9 Asc : © 181 | Dec : 170 Oct : 252 Hex : AA Asc : ª 182 | Dec : 171 Oct : 253 Hex : AB Asc : « 183 | Dec : 172 Oct : 254 Hex : AC Asc : ¬ 184 | Dec : 173 Oct : 255 Hex : AD Asc : ­ 185 | Dec : 174 Oct : 256 Hex : AE Asc : ® 186 | Dec : 175 Oct : 257 Hex : AF Asc : ¯ 187 | Dec : 176 Oct : 260 Hex : B0 Asc : ° 188 | Dec : 177 Oct : 261 Hex : B1 Asc : ± 189 | Dec : 178 Oct : 262 Hex : B2 Asc : ² 190 | Dec : 179 Oct : 263 Hex : B3 Asc : ³ 191 | Dec : 180 Oct : 264 Hex : B4 Asc : ´ 192 | Dec : 181 Oct : 265 Hex : B5 Asc : µ 193 | Dec : 182 Oct : 266 Hex : B6 Asc : ¶ 194 | Dec : 183 Oct : 267 Hex : B7 Asc : · 195 | Dec : 184 Oct : 270 Hex : B8 Asc : ¸ 196 | Dec : 185 Oct : 271 Hex : B9 Asc : ¹ 197 | Dec : 186 Oct : 272 Hex : BA Asc : º 198 | Dec : 187 Oct : 273 Hex : BB Asc : » 199 | Dec : 188 Oct : 274 Hex : BC Asc : ¼ 200 | Dec : 189 Oct : 275 Hex : BD Asc : ½ 201 | Dec : 190 Oct : 276 Hex : BE Asc : ¾ 202 | Dec : 191 Oct : 277 Hex : BF Asc : ¿ 203 | Dec : 192 Oct : 300 Hex : C0 Asc : À 204 | Dec : 193 Oct : 301 Hex : C1 Asc : Á 205 | Dec : 194 Oct : 302 Hex : C2 Asc :  206 | Dec : 195 Oct : 303 Hex : C3 Asc : à 207 | Dec : 196 Oct : 304 Hex : C4 Asc : Ä 208 | Dec : 197 Oct : 305 Hex : C5 Asc : Å 209 | Dec : 198 Oct : 306 Hex : C6 Asc : Æ 210 | Dec : 199 Oct : 307 Hex : C7 Asc : Ç 211 | Dec : 200 Oct : 310 Hex : C8 Asc : È 212 | Dec : 201 Oct : 311 Hex : C9 Asc : É 213 | Dec : 202 Oct : 312 Hex : CA Asc : Ê 214 | Dec : 203 Oct : 313 Hex : CB Asc : Ë 215 | Dec : 204 Oct : 314 Hex : CC Asc : Ì 216 | Dec : 205 Oct : 315 Hex : CD Asc : Í 217 | Dec : 206 Oct : 316 Hex : CE Asc : Î 218 | Dec : 207 Oct : 317 Hex : CF Asc : Ï 219 | Dec : 208 Oct : 320 Hex : D0 Asc : Ð 220 | Dec : 209 Oct : 321 Hex : D1 Asc : Ñ 221 | Dec : 210 Oct : 322 Hex : D2 Asc : Ò 222 | Dec : 211 Oct : 323 Hex : D3 Asc : Ó 223 | Dec : 212 Oct : 324 Hex : D4 Asc : Ô 224 | Dec : 213 Oct : 325 Hex : D5 Asc : Õ 225 | Dec : 214 Oct : 326 Hex : D6 Asc : Ö 226 | Dec : 215 Oct : 327 Hex : D7 Asc : × 227 | Dec : 216 Oct : 330 Hex : D8 Asc : Ø 228 | Dec : 217 Oct : 331 Hex : D9 Asc : Ù 229 | Dec : 218 Oct : 332 Hex : DA Asc : Ú 230 | Dec : 219 Oct : 333 Hex : DB Asc : Û 231 | Dec : 220 Oct : 334 Hex : DC Asc : Ü 232 | Dec : 221 Oct : 335 Hex : DD Asc : Ý 233 | Dec : 222 Oct : 336 Hex : DE Asc : Þ 234 | Dec : 223 Oct : 337 Hex : DF Asc : ß 235 | Dec : 224 Oct : 340 Hex : E0 Asc : à 236 | Dec : 225 Oct : 341 Hex : E1 Asc : á 237 | Dec : 226 Oct : 342 Hex : E2 Asc : â 238 | Dec : 227 Oct : 343 Hex : E3 Asc : ã 239 | Dec : 228 Oct : 344 Hex : E4 Asc : ä 240 | Dec : 229 Oct : 345 Hex : E5 Asc : å 241 | Dec : 230 Oct : 346 Hex : E6 Asc : æ 242 | Dec : 231 Oct : 347 Hex : E7 Asc : ç 243 | Dec : 232 Oct : 350 Hex : E8 Asc : è 244 | Dec : 233 Oct : 351 Hex : E9 Asc : é 245 | Dec : 234 Oct : 352 Hex : EA Asc : ê 246 | Dec : 235 Oct : 353 Hex : EB Asc : ë 247 | Dec : 236 Oct : 354 Hex : EC Asc : ì 248 | Dec : 237 Oct : 355 Hex : ED Asc : í 249 | Dec : 238 Oct : 356 Hex : EE Asc : î 250 | Dec : 239 Oct : 357 Hex : EF Asc : ï 251 | Dec : 240 Oct : 360 Hex : F0 Asc : ð 252 | Dec : 241 Oct : 361 Hex : F1 Asc : ñ 253 | Dec : 242 Oct : 362 Hex : F2 Asc : ò 254 | Dec : 243 Oct : 363 Hex : F3 Asc : ó 255 | Dec : 244 Oct : 364 Hex : F4 Asc : ô 256 | Dec : 245 Oct : 365 Hex : F5 Asc : õ 257 | Dec : 246 Oct : 366 Hex : F6 Asc : ö 258 | Dec : 247 Oct : 367 Hex : F7 Asc : ÷ 259 | Dec : 248 Oct : 370 Hex : F8 Asc : ø 260 | Dec : 249 Oct : 371 Hex : F9 Asc : ù 261 | Dec : 250 Oct : 372 Hex : FA Asc : ú 262 | Dec : 251 Oct : 373 Hex : FB Asc : û 263 | Dec : 252 Oct : 374 Hex : FC Asc : ü 264 | Dec : 253 Oct : 375 Hex : FD Asc : ý 265 | Dec : 254 Oct : 376 Hex : FE Asc : þ 266 | Dec : 255 Oct : 377 Hex : FF Asc : ÿ 267 | =undefined 268 | > 269 | -------------------------------------------------------------------------------- /ascii_characters_table/README.md: -------------------------------------------------------------------------------- 1 | # ASCII Characters Table 2 | 3 | **by Kay Anar in July 6, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | ASCII control characters (character code 0-31) 15 | 000 (00) 001 (01) 002 (02) 003 (03) 004 (04) 005 (05) 006 (06) 007 (07) 16 | 008 (08) 009 (09) 010 (0A) 011 (0B) 012 (0C) 013 (0D) 014 (0E) 015 (0F) 17 | 016 (10) 017 (11) 018 (12) 019 (13) 020 (14) 021 (15) 022 (16) 023 (17) 18 | 024 (18) 025 (19) 026 (1A) 027 (1B) 028 (1C) 029 (1D) 030 (1E) 031 (1F) 19 | ASCII printable characters (character code 32-127) 20 | 032 (20) 033 (21) ! 034 (22) " 035 (23) # 036 (24) $ 037 (25) % 038 (26) & 039 (27) ' 21 | 040 (28) ( 041 (29) ) 042 (2A) * 043 (2B) + 044 (2C) , 045 (2D) - 046 (2E) . 047 (2F) / 22 | 048 (30) 0 049 (31) 1 050 (32) 2 051 (33) 3 052 (34) 4 053 (35) 5 054 (36) 6 055 (37) 7 23 | 056 (38) 8 057 (39) 9 058 (3A) : 059 (3B) ; 060 (3C) < 061 (3D) = 062 (3E) > 063 (3F) ? 24 | 064 (40) @ 065 (41) A 066 (42) B 067 (43) C 068 (44) D 069 (45) E 070 (46) F 071 (47) G 25 | 072 (48) H 073 (49) I 074 (4A) J 075 (4B) K 076 (4C) L 077 (4D) M 078 (4E) N 079 (4F) O 26 | 080 (50) P 081 (51) Q 082 (52) R 083 (53) S 084 (5 ) T 085 (55) U 086 (56) V 087 (57) W 27 | 088 (58) X 089 (59) Y 090 (5A) Z 091 (5B) [ 092 (5C) \ 093 (5D) ] 094 (5E) ^ 095 (5F) _ 28 | 096 (60) ` 097 (61) a 098 (62) b 099 (63) c 100 (64) d 101 (65) e 102 (66) f 103 (67) g 29 | 104 (68) h 105 (69) i 106 (6A) j 107 (6B) k 108 (6C) l 109 (6D) m 110 (6E) n 111 (6F) o 30 | 112 (70) p 113 (71) q 114 (72) r 115 (73) s 116 (74) t 117 (75) u 118 (76) v 119 (77) w 31 | 120 (78) x 121 (79) y 122 (7A) z 123 (7B) { 124 (7C) | 125 (7D) } 126 (7E) ~ 127 (7F)  32 | The extended ASCII codes (character code 128-255) 33 | 128 (80) 129 (81) 130 (82) 131 (83) 132 (84) 133 (85) 134 (86) 135 (87) 34 | 136 (88) 137 (89) 138 (8A) 139 (8B) 140 (8C) 141 (8D) 142 (8E) 143 (8F) 35 | 144 (90) 145 (91) 146 (92) 147 (93) 148 (94) 149 (95) 150 (96) 151 (97) 36 | 152 (98) 153 (99) 154 (9A) 155 (9B) 156 (9C) 157 (9D) 158 (9E) 159 (9F) 37 | 160 (A0) 161 (A1) ¡ 162 (A2) ¢ 163 (A3) £ 164 (A4) ¤ 165 (A5) ¥ 166 (A6) ¦ 167 (A7) § 38 | 168 (A8) ¨ 169 (A9) © 170 (AA) ª 171 (AB) « 172 (AC) ¬ 173 (AD) 174 (AE) ® 175 (AF) ¯ 39 | 176 (B0) ° 177 (B1) ± 178 (B2) ² 179 (B3) ³ 180 (B4) ´ 181 (B5) µ 182 (B6) ¶ 183 (B7) · 40 | 184 (B8) ¸ 185 (B9) ¹ 186 (BA) º 187 (BB) » 188 (BC) ¼ 189 (BD) ½ 190 (BE) ¾ 191 (BF) ¿ 41 | 192 (C0) À 193 (C1) Á 194 (C2)  195 (C3) à 196 (C4) Ä 197 (C5) Å 198 (C6) Æ 199 (C7) Ç 42 | 200 (C8) È 201 (C9) É 202 (CA) Ê 203 (CB) Ë 204 (CC) Ì 205 (CD) Í 206 (CE) Î 207 (CF) Ï 43 | 208 (D0) Ð 209 (D1) Ñ 210 (D2) Ò 211 (D3) Ó 212 (D4) Ô 213 (D5) Õ 214 (D6) Ö 215 (D7) × 44 | 216 (D8) Ø 217 (D9) Ù 218 (DA) Ú 219 (DB) Û 220 (DC) Ü 221 (DD) Ý 222 (DE) Þ 223 (DF) ß 45 | 224 (E0) à 225 (E1) á 226 (E2) â 227 (E3) ã 228 (E4) ä 229 (E5) å 230 (E6) æ 231 (E7) ç 46 | 232 (E8) è 233 (E9) é 234 (EA) ê 235 (EB) ë 236 (EC) ì 237 (ED) í 238 (EE) î 239 (EF) ï 47 | 240 (F0) ð 241 (F1) ñ 242 (F2) ò 243 (F3) ó 244 (F4) ô 245 (F5) õ 246 (F6) ö 247 (F7) ÷ 48 | 248 (F8) ø 249 (F9) ù 250 (FA) ú 251 (FB) û 252 (FC) ü 253 (FD) ý 254 (FE) þ 255 (FF) ÿ 49 | =undefined 50 | > 51 | ```` 52 | 53 | 54 | ## Bug tracker 55 | 56 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 57 | 58 | ## Twitter account 59 | 60 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 61 | 62 | ## Contributing 63 | 64 | 1. Fork it. 65 | 2. Create a branch (`git checkout -b myEspruino`) 66 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 67 | 4. Push to the branch (`git push origin myEspruino`) 68 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 69 | 70 | ## License 71 | 72 | Espruino by Examples < http://git.io/ebe > 73 | 74 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 75 | 76 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 77 | 78 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 79 | 80 | 81 | -------------------------------------------------------------------------------- /ascii_characters_table/ascii_characters_table.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | ASCII Characters Table 21 | by Kay Anar in July 6, 2014 22 | 23 | */ 24 | 25 | function asciiTable() 26 | { 27 | for(var index = 0; index < 256 ; index += 8) 28 | { 29 | if (index == 0) 30 | print("ASCII control characters (character code 0-31)"); 31 | else if (index == 32) 32 | print("ASCII printable characters (character code 32-127)"); 33 | else if (index == 128) 34 | print("The extended ASCII codes (character code 128-255)"); 35 | var output = ""; 36 | for(var offset = 0; offset < 8; offset++) 37 | { 38 | if (offset != 0) 39 | output += " "; 40 | output += ((index + offset) < 10 ? "00" : ((index + offset) < 100 ? "0" : "")) + (index + offset); 41 | output += " ("; 42 | output += ((index + offset) < 16 ? "0" : "") + (index + offset).toString(16).toUpperCase(); 43 | output += ")"; 44 | output += " "; 45 | if ((index + offset > 31 && index + offset < 128) || (index + offset > 160 && index + offset < 256 && index + offset != 173)) 46 | output += String.fromCharCode(index + offset); 47 | else 48 | output += " "; 49 | } 50 | print(output); 51 | output = null; 52 | } 53 | } 54 | 55 | function onInit() 56 | { 57 | asciiTable(); 58 | } 59 | 60 | onInit(); -------------------------------------------------------------------------------- /ascii_characters_table/ascii_characters_table.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | ASCII control characters (character code 0-31) 9 | 000 (00) 001 (01) 002 (02) 003 (03) 004 (04) 005 (05) 006 (06) 007 (07) 10 | 008 (08) 009 (09) 010 (0A) 011 (0B) 012 (0C) 013 (0D) 014 (0E) 015 (0F) 11 | 016 (10) 017 (11) 018 (12) 019 (13) 020 (14) 021 (15) 022 (16) 023 (17) 12 | 024 (18) 025 (19) 026 (1A) 027 (1B) 028 (1C) 029 (1D) 030 (1E) 031 (1F) 13 | ASCII printable characters (character code 32-127) 14 | 032 (20) 033 (21) ! 034 (22) " 035 (23) # 036 (24) $ 037 (25) % 038 (26) & 039 (27) ' 15 | 040 (28) ( 041 (29) ) 042 (2A) * 043 (2B) + 044 (2C) , 045 (2D) - 046 (2E) . 047 (2F) / 16 | 048 (30) 0 049 (31) 1 050 (32) 2 051 (33) 3 052 (34) 4 053 (35) 5 054 (36) 6 055 (37) 7 17 | 056 (38) 8 057 (39) 9 058 (3A) : 059 (3B) ; 060 (3C) < 061 (3D) = 062 (3E) > 063 (3F) ? 18 | 064 (40) @ 065 (41) A 066 (42) B 067 (43) C 068 (44) D 069 (45) E 070 (46) F 071 (47) G 19 | 072 (48) H 073 (49) I 074 (4A) J 075 (4B) K 076 (4C) L 077 (4D) M 078 (4E) N 079 (4F) O 20 | 080 (50) P 081 (51) Q 082 (52) R 083 (53) S 084 (5 ) T 085 (55) U 086 (56) V 087 (57) W 21 | 088 (58) X 089 (59) Y 090 (5A) Z 091 (5B) [ 092 (5C) \ 093 (5D) ] 094 (5E) ^ 095 (5F) _ 22 | 096 (60) ` 097 (61) a 098 (62) b 099 (63) c 100 (64) d 101 (65) e 102 (66) f 103 (67) g 23 | 104 (68) h 105 (69) i 106 (6A) j 107 (6B) k 108 (6C) l 109 (6D) m 110 (6E) n 111 (6F) o 24 | 112 (70) p 113 (71) q 114 (72) r 115 (73) s 116 (74) t 117 (75) u 118 (76) v 119 (77) w 25 | 120 (78) x 121 (79) y 122 (7A) z 123 (7B) { 124 (7C) | 125 (7D) } 126 (7E) ~ 127 (7F)  26 | The extended ASCII codes (character code 128-255) 27 | 128 (80) 129 (81) 130 (82) 131 (83) 132 (84) 133 (85) 134 (86) 135 (87) 28 | 136 (88) 137 (89) 138 (8A) 139 (8B) 140 (8C) 141 (8D) 142 (8E) 143 (8F) 29 | 144 (90) 145 (91) 146 (92) 147 (93) 148 (94) 149 (95) 150 (96) 151 (97) 30 | 152 (98) 153 (99) 154 (9A) 155 (9B) 156 (9C) 157 (9D) 158 (9E) 159 (9F) 31 | 160 (A0) 161 (A1) ¡ 162 (A2) ¢ 163 (A3) £ 164 (A4) ¤ 165 (A5) ¥ 166 (A6) ¦ 167 (A7) § 32 | 168 (A8) ¨ 169 (A9) © 170 (AA) ª 171 (AB) « 172 (AC) ¬ 173 (AD) 174 (AE) ® 175 (AF) ¯ 33 | 176 (B0) ° 177 (B1) ± 178 (B2) ² 179 (B3) ³ 180 (B4) ´ 181 (B5) µ 182 (B6) ¶ 183 (B7) · 34 | 184 (B8) ¸ 185 (B9) ¹ 186 (BA) º 187 (BB) » 188 (BC) ¼ 189 (BD) ½ 190 (BE) ¾ 191 (BF) ¿ 35 | 192 (C0) À 193 (C1) Á 194 (C2)  195 (C3) à 196 (C4) Ä 197 (C5) Å 198 (C6) Æ 199 (C7) Ç 36 | 200 (C8) È 201 (C9) É 202 (CA) Ê 203 (CB) Ë 204 (CC) Ì 205 (CD) Í 206 (CE) Î 207 (CF) Ï 37 | 208 (D0) Ð 209 (D1) Ñ 210 (D2) Ò 211 (D3) Ó 212 (D4) Ô 213 (D5) Õ 214 (D6) Ö 215 (D7) × 38 | 216 (D8) Ø 217 (D9) Ù 218 (DA) Ú 219 (DB) Û 220 (DC) Ü 221 (DD) Ý 222 (DE) Þ 223 (DF) ß 39 | 224 (E0) à 225 (E1) á 226 (E2) â 227 (E3) ã 228 (E4) ä 229 (E5) å 230 (E6) æ 231 (E7) ç 40 | 232 (E8) è 233 (E9) é 234 (EA) ê 235 (EB) ë 236 (EC) ì 237 (ED) í 238 (EE) î 239 (EF) ï 41 | 240 (F0) ð 241 (F1) ñ 242 (F2) ò 243 (F3) ó 244 (F4) ô 245 (F5) õ 246 (F6) ö 247 (F7) ÷ 42 | 248 (F8) ø 249 (F9) ù 250 (FA) ú 251 (FB) û 252 (FC) ü 253 (FD) ý 254 (FE) þ 255 (FF) ÿ 43 | =undefined 44 | > -------------------------------------------------------------------------------- /bare_minimum/README.md: -------------------------------------------------------------------------------- 1 | # Bare Minimum 2 | 3 | **by Kay Anar in July 14, 2014 ** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /bare_minimum/bare_minimum.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Bare Minimum 21 | by Kay Anar in July 14, 2014 22 | 23 | */ 24 | 25 | function onInit() 26 | { 27 | // put your setup code here, to run once 28 | } 29 | 30 | // call the onInit() function 31 | onInit(); -------------------------------------------------------------------------------- /board_info/README.md: -------------------------------------------------------------------------------- 1 | # Board Info 2 | 3 | **by Kay Anar in July 4, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | Formatted Espruino Information 15 | 16 | Board 17 | ----- 18 | Name : ESPRUINOBOARD 19 | Chip : STM32F103RCT6 20 | Chip Family : STM32F1 21 | RAM : 49152 Bytes (48.0 KB) 22 | Serial # : 33ffd905-41573033-37640843 23 | Console : USB 24 | Voltage : 3.3 Volts 25 | Temperature : 35.9 Celsius 26 | 27 | Firmware 28 | ----- 29 | Version : 1v67 30 | Build Date : Jul 11 2014 31 | Build Time : 10:47:25 32 | Git Commit : f33296cc25b4ef83ddbd8277986a713795d10d11 33 | 34 | Random Access Memory 35 | -------------------- 36 | Free : 1606 Bytes (1.582 KB) 37 | Used : 97 Bytes 38 | Total : 1800 Bytes (1.776 KB) 39 | History : 132 Bytes 40 | 41 | Flash Memory 42 | ------------ 43 | Size : 262144 Bytes (256.0 KB) 44 | Starts : 134217728 (0x8000000) 45 | Ends : 134479872 (0x8040000) 46 | 47 | User Flash Memory 48 | ----------------- 49 | Size : 52988 Bytes (51.764 KB) 50 | Starts : 134390020 (0x802A104) 51 | Ends : 134443008 (0x8037000) 52 | 53 | Binary 54 | ------ 55 | Starts : 134227968 (0x8002800) 56 | Ends : 134390020 (0x802A104) 57 | Size : 162052 Bytes (158.260 KB) 58 | 59 | Code 60 | ---- 61 | Starts : 134443008 (0x8037000) 62 | Ends : 134479872 (0x8040000) 63 | Size : 36864 Bytes (36.0 KB) 64 | =undefined 65 | > 66 | ```` 67 | 68 | 69 | ## Bug tracker 70 | 71 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 72 | 73 | ## Twitter account 74 | 75 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 76 | 77 | ## Contributing 78 | 79 | 1. Fork it. 80 | 2. Create a branch (`git checkout -b myEspruino`) 81 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 82 | 4. Push to the branch (`git push origin myEspruino`) 83 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 84 | 85 | ## License 86 | 87 | Espruino by Examples < http://git.io/ebe > 88 | 89 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 90 | 91 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 92 | 93 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 94 | 95 | 96 | -------------------------------------------------------------------------------- /board_info/board_info.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Board Info 21 | by Kay Anar in July 4, 2014 22 | 23 | This script prints detail board, firmware, ram, flash information. 24 | 25 | Internal flash memory on the chip : 26 | +---------+ 27 | |0x8000000| -> process.memory().flash_start 28 | | | 29 | |0x8002800| -> Bootloader ends 30 | | | 31 | | | 32 | | | 33 | |0x80351E4| -> process.memory().flash_binary_end 34 | | | -> spare flash memory area 35 | |0x8037000| -> process.memory().flash_code_start 36 | | | 37 | | | 38 | | | 39 | |0x8040000| -> process.memory().flash_start + process.memory().flash_length 40 | +---------+ 41 | 42 | More information about internal flash memory on the chip is 43 | at http://www.espruino.com/STM32F1Flash 44 | 45 | */ 46 | 47 | var BINARY_STARTS = 134227968; 48 | 49 | function formatMemory(value) 50 | { 51 | if ((value >> 10) & 0x3FF) 52 | value = value + " Bytes (" + (value >>> 10) + "." + (value & (0x3FF)) + " KB)"; 53 | else if ((value >> 1) & 0x3FF) 54 | value = (value >>> 1) + " Bytes"; 55 | else 56 | value = value + " Byte"; 57 | return(value); 58 | } 59 | 60 | function formatAddress(value) 61 | { 62 | return(value + " (0x" + value.toString(16).toUpperCase() + ")"); 63 | } 64 | 65 | function onInit() 66 | { 67 | var memory = process.memory(); 68 | 69 | print("Formatted Espruino Information"); 70 | print(" "); 71 | print("Board"); 72 | print("-----"); 73 | print("Name :", process.env.BOARD); 74 | print("Chip :", process.env.CHIP); 75 | print("Chip Family :", process.env.CHIP_FAMILY); 76 | print("RAM :", formatMemory(process.env.RAM)); 77 | print("Serial # :", process.env.SERIAL); 78 | print("Console :", process.env.CONSOLE); 79 | print("Voltage :", Math.round(E.getAnalogVRef() * 10) / 10, "Volts"); 80 | print("Temperature :", Math.round(E.getTemperature() * 10) / 10, "Celsius"); 81 | print(" "); 82 | print("Firmware"); 83 | print("-----"); 84 | print("Version :", process.env.VERSION); 85 | print("Build Date :", process.env.BUILD_DATE); 86 | print("Build Time :", process.env.BUILD_TIME); 87 | print("Git Commit :", process.env.GIT_COMMIT); 88 | print(" "); 89 | print("Random Access Memory"); 90 | print("--------------------"); 91 | print("Free :", formatMemory(memory.free)); 92 | print("Used :", formatMemory(memory.usage)); 93 | print("Total :", formatMemory(memory.total)); 94 | print("History :", formatMemory(memory.history)); 95 | print(" "); 96 | print("Flash Memory"); 97 | print("------------"); 98 | print("Size :", formatMemory(memory.flash_length)); 99 | print("Starts :", formatAddress(memory.flash_start)); 100 | print("Ends :", formatAddress(memory.flash_start + memory.flash_length)); 101 | print(" "); 102 | print("User Flash Memory"); 103 | print("-----------------"); 104 | print("Size :", formatMemory(memory.flash_code_start - memory.flash_binary_end)); 105 | print("Starts :", formatAddress(memory.flash_binary_end)); 106 | print("Ends :", formatAddress(memory.flash_code_start)); 107 | print(" "); 108 | print("Binary"); 109 | print("------"); 110 | print("Starts :", formatAddress(BINARY_STARTS)); 111 | print("Ends :", formatAddress(memory.flash_binary_end)); 112 | print("Size :", formatMemory(memory.flash_binary_end - BINARY_STARTS)); 113 | print(" "); 114 | print("Code"); 115 | print("----"); 116 | print("Starts :", formatAddress(memory.flash_code_start)); 117 | print("Ends :", formatAddress(memory.flash_start + memory.flash_length)); 118 | print("Size :", formatMemory(memory.flash_start + memory.flash_length - memory.flash_code_start)); 119 | memory = null; 120 | } 121 | 122 | onInit(); -------------------------------------------------------------------------------- /board_info/board_info.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Formatted Espruino Information 9 | 10 | Board 11 | ----- 12 | Name : ESPRUINOBOARD 13 | Chip : STM32F103RCT6 14 | Chip Family : STM32F1 15 | RAM : 49152 Bytes (48.0 KB) 16 | Serial # : 33ffd905-41573033-37640843 17 | Console : USB 18 | Voltage : 3.3 Volts 19 | Temperature : 35.9 Celsius 20 | 21 | Firmware 22 | ----- 23 | Version : 1v67 24 | Build Date : Jul 11 2014 25 | Build Time : 10:47:25 26 | Git Commit : f33296cc25b4ef83ddbd8277986a713795d10d11 27 | 28 | Random Access Memory 29 | -------------------- 30 | Free : 1606 Bytes (1.582 KB) 31 | Used : 97 Bytes 32 | Total : 1800 Bytes (1.776 KB) 33 | History : 132 Bytes 34 | 35 | Flash Memory 36 | ------------ 37 | Size : 262144 Bytes (256.0 KB) 38 | Starts : 134217728 (0x8000000) 39 | Ends : 134479872 (0x8040000) 40 | 41 | User Flash Memory 42 | ----------------- 43 | Size : 52988 Bytes (51.764 KB) 44 | Starts : 134390020 (0x802A104) 45 | Ends : 134443008 (0x8037000) 46 | 47 | Binary 48 | ------ 49 | Starts : 134227968 (0x8002800) 50 | Ends : 134390020 (0x802A104) 51 | Size : 162052 Bytes (158.260 KB) 52 | 53 | Code 54 | ---- 55 | Starts : 134443008 (0x8037000) 56 | Ends : 134479872 (0x8040000) 57 | Size : 36864 Bytes (36.0 KB) 58 | =undefined 59 | > -------------------------------------------------------------------------------- /decision_maker/README.md: -------------------------------------------------------------------------------- 1 | # Decision Maker 2 | 3 | **by Kay Anar in June 24, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /decision_maker/decision_maker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Decision Maker 21 | by Kay Anar in June 24, 2014 22 | 23 | A random coin flip or coin toss or yes/no to make those hard 50/50 decisions. 24 | 25 | You may assume LED1 red as "no" or "tails" and LED2 green as "yes" or "heads" 26 | 27 | */ 28 | 29 | // Define and initialize the variables 30 | // Current light time out value 31 | var timeOutValue = 0; 32 | // Current light 33 | var light = 0; 34 | 35 | function button_down() 36 | { 37 | // Set timeOutValue to 50 milliseconds 38 | timeOutValue = 50; 39 | // Call the function flip_flop ONCE after the timeout in milliseconds. 40 | setTimeout(flip_flop, timeOutValue); 41 | } 42 | 43 | function flip_flop() 44 | { 45 | // Clear the Timeout that was created with setTimeout 46 | clearTimeout(timeOutHandler); 47 | if (timeOutValue < 1000) 48 | { 49 | timeOutValue += Math.random() * 50; 50 | light = !light; 51 | // If number is 0, LED1 turns on 52 | LED1.write(light == 0); 53 | // If number is 1, LED2 turns on 54 | LED2.write(light == 1); 55 | setTimeout(flip_flop, timeOutValue); 56 | } 57 | } 58 | 59 | // Call the function 'button_down' when the button pressed 60 | setWatch(button_down, BTN, true); -------------------------------------------------------------------------------- /digital_multiple_read/README.md: -------------------------------------------------------------------------------- 1 | # Digital Multiple Read 2 | 3 | **by Kay Anar in July 14, 2014 ** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | Integer = 7 15 | Binary = 111 16 | =undefined 17 | > 18 | ```` 19 | 20 | 21 | ## Bug tracker 22 | 23 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 24 | 25 | ## Twitter account 26 | 27 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 28 | 29 | ## Contributing 30 | 31 | 1. Fork it. 32 | 2. Create a branch (`git checkout -b myEspruino`) 33 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 34 | 4. Push to the branch (`git push origin myEspruino`) 35 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 36 | 37 | ## License 38 | 39 | Espruino by Examples < http://git.io/ebe > 40 | 41 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 42 | 43 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 44 | 45 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 46 | 47 | 48 | -------------------------------------------------------------------------------- /digital_multiple_read/digital_multiple_read.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Digital Multiple Read 21 | by Kay Anar in July 14, 2014 22 | 23 | */ 24 | 25 | var PINS = [C5, C4, C6]; 26 | 27 | function onInit() 28 | { 29 | // read the pins' digital values 30 | var pinValues = digitalRead(PINS); 31 | 32 | // print out the values you read as Integer 33 | print("Integer =", pinValues); 34 | // print out the values you read as Binary 35 | print("Binary =", pinValues.toString(2)); 36 | } 37 | 38 | // call the onInit() function 39 | onInit(); -------------------------------------------------------------------------------- /digital_multiple_read/digital_multiple_read.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Integer = 7 9 | Binary = 111 10 | =undefined 11 | > -------------------------------------------------------------------------------- /digital_read/README.md: -------------------------------------------------------------------------------- 1 | # Digital Read Example 2 | 3 | **by Kay Anar in July 14, 2014 ** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | 1 15 | =undefined 16 | > 17 | ```` 18 | 19 | 20 | ## Bug tracker 21 | 22 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 23 | 24 | ## Twitter account 25 | 26 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 27 | 28 | ## Contributing 29 | 30 | 1. Fork it. 31 | 2. Create a branch (`git checkout -b myEspruino`) 32 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 33 | 4. Push to the branch (`git push origin myEspruino`) 34 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 35 | 36 | ## License 37 | 38 | Espruino by Examples < http://git.io/ebe > 39 | 40 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 41 | 42 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 43 | 44 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 45 | 46 | 47 | -------------------------------------------------------------------------------- /digital_read/digital_read.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Digital Read Example 21 | by Kay Anar in July 14, 2014 22 | 23 | */ 24 | 25 | var PIN = C4; 26 | 27 | function onInit() 28 | { 29 | // read the pin's digital value 30 | var pinValue = digitalRead(PIN); 31 | 32 | // print out the value you read 33 | print(pinValue); 34 | } 35 | 36 | // call the onInit() function 37 | onInit(); 38 | 39 | 40 | -------------------------------------------------------------------------------- /digital_read/digital_read.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | 1 9 | =undefined 10 | > -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/docs/favicon.ico -------------------------------------------------------------------------------- /docs/styles.css: -------------------------------------------------------------------------------- 1 | 2 | html { 3 | color: #000000; 4 | font-family: sans-serif; 5 | } 6 | body { 7 | margin-top: 5px; 8 | } 9 | .section { 10 | background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 0%, rgba(246, 246, 246, 1) 47%, rgba(237, 237, 237, 1) 100%) repeat scroll 0 0 rgba(0, 0, 0, 0); 11 | border-radius: 10px; 12 | box-shadow: 3px 3px 10px 0; 13 | margin: 20px 15px 0 0; 14 | padding: 0 10px 10px; 15 | } 16 | h1 { 17 | display: block; 18 | height: 0; 19 | margin-top: 0; 20 | text-shadow: 2px 2px 3px #888888; 21 | white-space: nowrap; 22 | } 23 | h2 { 24 | color: #333333; 25 | display: block; 26 | font-size: 125%; 27 | margin-bottom: 5px; 28 | margin-top: 8px; 29 | text-shadow: 2px 2px 3px #888888; 30 | white-space: nowrap; 31 | } 32 | small { 33 | color: #333333; 34 | display: block; 35 | margin-bottom: 10px; 36 | margin-right: 10px; 37 | margin-top: 20px; 38 | text-align: right; 39 | text-shadow: 2px 2px 3px #888888; 40 | white-space: nowrap; 41 | } 42 | code { 43 | display: block; 44 | height: 1.25em; 45 | white-space: nowrap; 46 | } 47 | .function { 48 | color: #00008b; 49 | } 50 | .constructor { 51 | color: #00008b; 52 | } 53 | .event { 54 | color: #00008b; 55 | } 56 | .bracket { 57 | color: #006400; 58 | } 59 | .constant { 60 | color: #0000ff; 61 | } 62 | .property { 63 | color: #0000ff; 64 | } 65 | .param { 66 | color: #8b0000; 67 | } 68 | .punctuation { 69 | color: #000000; 70 | } 71 | a { 72 | text-decoration: none; 73 | } 74 | -------------------------------------------------------------------------------- /extended_array_object/README.md: -------------------------------------------------------------------------------- 1 | # Extended Array Object 2 | 3 | **by Kay Anar in July 11, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | 15 | false 16 | 17 | true 18 | 19 | -1 20 | 21 | 2 22 | =undefined 23 | > 24 | ```` 25 | 26 | 27 | ## Bug tracker 28 | 29 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 30 | 31 | ## Twitter account 32 | 33 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 34 | 35 | ## Contributing 36 | 37 | 1. Fork it. 38 | 2. Create a branch (`git checkout -b myEspruino`) 39 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 40 | 4. Push to the branch (`git push origin myEspruino`) 41 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 42 | 43 | ## License 44 | 45 | Espruino by Examples < http://git.io/ebe > 46 | 47 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 48 | 49 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 50 | 51 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 52 | 53 | 54 | -------------------------------------------------------------------------------- /extended_array_object/extended_array_object.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Extended Array Object 21 | by Kay Anar in July 11, 2014 22 | 23 | This script extends Array object, adds new functions 24 | 25 | */ 26 | 27 | // Returns true if this list contains the specified value. 28 | Array.prototype.contains = function (value) 29 | { 30 | for (var index = 0; index < this.length; index++) 31 | if (this[index] == value) 32 | return(true); 33 | return(false); 34 | }; 35 | 36 | // Returns the index within this string of the first occurrence of the specified value. 37 | Array.prototype.indexOf = function (value) 38 | { 39 | for (var index = 0; index < this.length; index++) 40 | if (this[index] == value) 41 | return(index); 42 | return(-1); 43 | }; 44 | 45 | print(" "); 46 | print([1, 4, 5].contains(3)); 47 | // prints false 48 | 49 | print(" "); 50 | print([1, 4, 5].contains(5)); 51 | // prints true 52 | 53 | print(" "); 54 | print([1, 4, 5].indexOf(3)); 55 | // prints -1 56 | 57 | print(" "); 58 | print([1, 4, 5].indexOf(5)); 59 | // prints 2 -------------------------------------------------------------------------------- /extended_array_object/extended_array_object.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | 9 | false 10 | 11 | true 12 | 13 | -1 14 | 15 | 2 16 | =undefined 17 | > -------------------------------------------------------------------------------- /extended_math_object/README.md: -------------------------------------------------------------------------------- 1 | # Extended Math Object 2 | 3 | **by Kay Anar in July 3, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | 15 | Math.map(512, 0, 1023, 0, 100); 16 | 50.04887585532 17 | 18 | Math.map(-512, 0, 1023, 0, 100); 19 | -50.04887585532 20 | 21 | Math.constrain(Math.map(-512, 0, 1023, 0, 100), 0, 1023); 22 | 0 23 | 24 | Math.floatToInt(Math.map(512, 0, 1023, 0, 100)); 25 | 50 26 | =undefined 27 | > 28 | ```` 29 | 30 | 31 | ## Bug tracker 32 | 33 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 34 | 35 | ## Twitter account 36 | 37 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 38 | 39 | ## Contributing 40 | 41 | 1. Fork it. 42 | 2. Create a branch (`git checkout -b myEspruino`) 43 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 44 | 4. Push to the branch (`git push origin myEspruino`) 45 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 46 | 47 | ## License 48 | 49 | Espruino by Examples < http://git.io/ebe > 50 | 51 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 52 | 53 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 54 | 55 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 56 | 57 | 58 | -------------------------------------------------------------------------------- /extended_math_object/extended_math_object.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Extended Math Object 21 | by Kay Anar in July 3, 2014 22 | 23 | This script extends Math object, adds new functions 24 | 25 | */ 26 | 27 | // This function re-maps a number from one range to another. 28 | // That is, a value of fromLow would get mapped to toLow, 29 | // a value of fromHigh to toHigh, values in-between to values 30 | // in-between, etc. 31 | // 32 | // Does not constrain values to within the range, because 33 | // out-of-range values are sometimes intended and useful. 34 | // The Math.constrain function may be used either before or 35 | // after this function, if limits to the ranges are desired. 36 | // 37 | // Note that the "lower bounds" of either range may be larger 38 | // or smaller than the "upper bounds" so the Math.map function 39 | // may be used to reverse a range of numbers, for example 40 | // 41 | // var y = Math.map(x, 1, 50, 50, 1); 42 | // 43 | // The function also handles negative numbers well, so that this example 44 | // 45 | // var y = Math.map(x, 1, 50, 50, -100); 46 | // 47 | // is also valid and works well. 48 | // 49 | // Ported from Arduino map function at http://arduino.cc/en/reference/map 50 | // 51 | Math.map = function(value, fromLow, fromHigh, toLow, toHigh) 52 | { 53 | return ((value - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow); 54 | }; 55 | 56 | // This function converts a floating-point (such as 3.14) number 57 | // to an integer (such as 3) 58 | // 59 | // The bitwise operators perform low-level manipulation of the bits 60 | // in the binary representation of numbers. The bitwise operators 61 | // expect integer operands and behave as if those values were represented 62 | // as 32-bit integers rather than 64-bit floating-point values. 63 | // These operators convert their operands to numbers, if necessary, 64 | // and then coerce the numeric values to 32-bit integers by dropping 65 | // any fractional part and any bits beyond the 32nd. 66 | // 67 | // There are other ways to convert a floating-point (such as 3.14) number 68 | // to an integer (such as 3); in standard Javascript, you may call Math.floor 69 | // function and in Espruino Javascript, you may call Double.doubleToIntBits 70 | // 71 | Math.floatToInt = function(float) 72 | { 73 | return(float | 0); 74 | }; 75 | 76 | // This function constrains a number to be within a range. 77 | // 78 | // Ported from Arduino map function at http://arduino.cc/en/Reference/Constrain 79 | // 80 | Math.constrain = function(value, lowerVal, upperVal) 81 | { 82 | if (value > upperVal) 83 | value = upperVal; 84 | else if (value < lowerVal) 85 | value = lowerVal; 86 | return (value); 87 | }; 88 | 89 | print(" "); 90 | print("Math.map(512, 0, 1023, 0, 100);"); 91 | print(Math.map(512, 0, 1023, 0, 100)); 92 | // prints 50.0488758553274664109267177991569042205810546875 93 | 94 | print(" "); 95 | print("Math.map(-512, 0, 1023, 0, 100);"); 96 | print(Math.map(-512, 0, 1023, 0, 100)); 97 | // prints -50.0488758553274664109267177991569042205810546875 98 | 99 | print(" "); 100 | print("Math.constrain(Math.map(-512, 0, 1023, 0, 100), 0, 1023);"); 101 | print(Math.constrain(Math.map(-512, 0, 1023, 0, 100), 0, 1023)); 102 | // prints 0 103 | 104 | print(" "); 105 | print("Math.floatToInt(Math.map(512, 0, 1023, 0, 100));"); 106 | print(Math.floatToInt(Math.map(512, 0, 1023, 0, 100))); 107 | // prints 50 -------------------------------------------------------------------------------- /extended_math_object/extended_math_object.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | 9 | Math.map(512, 0, 1023, 0, 100); 10 | 50.04887585532 11 | 12 | Math.map(-512, 0, 1023, 0, 100); 13 | -50.04887585532 14 | 15 | Math.constrain(Math.map(-512, 0, 1023, 0, 100), 0, 1023); 16 | 0 17 | 18 | Math.floatToInt(Math.map(512, 0, 1023, 0, 100)); 19 | 50 20 | =undefined 21 | > -------------------------------------------------------------------------------- /extended_string_object/README.md: -------------------------------------------------------------------------------- 1 | # Extended Array Object 2 | 3 | **by Kay Anar in July 11, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67_Copyright 2014 G.Williams 13 | >echo(0); 14 | Free memory 1714 bytes of total 1800 bytes. 15 | =undefined 16 | > 17 | ```` 18 | 19 | 20 | ## Bug tracker 21 | 22 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 23 | 24 | ## Twitter account 25 | 26 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 27 | 28 | ## Contributing 29 | 30 | 1. Fork it. 31 | 2. Create a branch (`git checkout -b myEspruino`) 32 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 33 | 4. Push to the branch (`git push origin myEspruino`) 34 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 35 | 36 | ## License 37 | 38 | Espruino by Examples < http://git.io/ebe > 39 | 40 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 41 | 42 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 43 | 44 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 45 | 46 | 47 | -------------------------------------------------------------------------------- /extended_string_object/extended_string_object.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Extended Array Object 21 | by Kay Anar in July 11, 2014 22 | 23 | This script extends Array object, adds new functions 24 | 25 | */ 26 | 27 | String.prototype.template = function (objVar) 28 | { 29 | var strVar = this; 30 | if(typeof objVar === "object") 31 | { 32 | var length = strVar.length; 33 | var start = -1; 34 | var key = ""; 35 | for(var index = 0; index < length; index++) 36 | { 37 | if (strVar.charAt(index) == '{' && start == -1) 38 | start = index; 39 | else if (strVar.charAt(index) == '}' && start != -1) 40 | { 41 | strVar = strVar.substring(0, start) + objVar[key] + strVar.substring(index + 1); 42 | start = -1; 43 | key = ""; 44 | length = strVar.length; 45 | } 46 | else if (start != -1) 47 | { 48 | key += strVar.charAt(index); 49 | } 50 | } 51 | } 52 | return(strVar); 53 | }; 54 | 55 | print("Free memory {free} bytes of total {total} bytes.".template(process.memory())); 56 | // prints Free memory 1716 bytes of total 1800 bytes. -------------------------------------------------------------------------------- /extended_string_object/extended_string_object.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67_Copyright 2014 G.Williams 7 | >echo(0); 8 | Free memory 1714 bytes of total 1800 bytes. 9 | =undefined 10 | > -------------------------------------------------------------------------------- /infinitive_save/README.md: -------------------------------------------------------------------------------- 1 | # Infinitive Save 2 | 3 | **by Kay Anar in July 17, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | =undefined 15 | Erasing Flash..................... 16 | Programming 36000 Bytes....................................... 17 | Checking... 18 | Done! 19 | Running onInit()... 20 | >Erasing Flash..................... 21 | Programming 36000 Bytes....................................... 22 | Checking... 23 | Done! 24 | Running onInit()... 25 | Erasing Flash..................... 26 | 6rogramming 36000 Bytes....................................... 27 | Checking... 28 | Done! 29 | Running onInit()... 30 | Erasing Flash..................... 31 | Programming 36000 Bytes....................................... 32 | Checking... 33 | Done! 34 | Running onInit()... 35 | Erasing Flash..................... 36 | Programming 36000 Bytes....................................... 37 | Checking... 38 | Done! 39 | Running onInit()... 40 | Erasing Flash..................... 41 | Programming 36000 Bytes....................................... 42 | Checking... 43 | Done! 44 | Running onInit()... 45 | Erasing Flash..................... 46 | Programming 36000 Bytes....................................... 47 | Checking... 48 | Done! 49 | Running onInit()... 50 | Erasing Flash..................... 51 | Programming 36000 Bytes............. 52 | 53 | ```` 54 | 55 | 56 | ## Bug tracker 57 | 58 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 59 | 60 | ## Twitter account 61 | 62 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 63 | 64 | ## Contributing 65 | 66 | 1. Fork it. 67 | 2. Create a branch (`git checkout -b myEspruino`) 68 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 69 | 4. Push to the branch (`git push origin myEspruino`) 70 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 71 | 72 | ## License 73 | 74 | Espruino by Examples < http://git.io/ebe > 75 | 76 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 77 | 78 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 79 | 80 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 81 | 82 | 83 | -------------------------------------------------------------------------------- /infinitive_save/infinitive_save.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Infinitive Save 21 | by Kay Anar in July 17, 2014 22 | 23 | */ 24 | function onInit() 25 | { 26 | save(); 27 | } 28 | 29 | onInit(); -------------------------------------------------------------------------------- /infinitive_save/infinitive_save.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | =undefined 9 | Erasing Flash..................... 10 | Programming 36000 Bytes....................................... 11 | Checking... 12 | Done! 13 | Running onInit()... 14 | >Erasing Flash..................... 15 | Programming 36000 Bytes....................................... 16 | Checking... 17 | Done! 18 | Running onInit()... 19 | Erasing Flash..................... 20 | 6rogramming 36000 Bytes....................................... 21 | Checking... 22 | Done! 23 | Running onInit()... 24 | Erasing Flash..................... 25 | Programming 36000 Bytes....................................... 26 | Checking... 27 | Done! 28 | Running onInit()... 29 | Erasing Flash..................... 30 | Programming 36000 Bytes....................................... 31 | Checking... 32 | Done! 33 | Running onInit()... 34 | Erasing Flash..................... 35 | Programming 36000 Bytes....................................... 36 | Checking... 37 | Done! 38 | Running onInit()... 39 | Erasing Flash..................... 40 | Programming 36000 Bytes....................................... 41 | Checking... 42 | Done! 43 | Running onInit()... 44 | Erasing Flash..................... 45 | Programming 36000 Bytes............. 46 | -------------------------------------------------------------------------------- /list_pins_with_modes/README.md: -------------------------------------------------------------------------------- 1 | # List Pins with Modes 2 | 3 | **by Kay Anar on July 15, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | Pin Modes : 15 | 00 01 _ 02 03 04_ 05 06 07 08 09 10 11 12 13 14 15 16 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 17 | A | in | in | in | in | in | in | in | in | in | ao | iu | ud | ud | in | in | in | 18 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 19 | B | in | in | in | in | in | in | in | in | in | in | in | in | in | ud | ud | ud | 20 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 21 | C | in | in | in | in | in | in | in | in | in | in | in | in | in | op | in | in | 22 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 23 | D | in | in | ud | na | na | na | na | na | na | na | na | na | na | na | na | na | 24 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 25 | Legend : 26 | in : Input iu : Input Pull Up id : Input Pull Down 27 | op : Output od : Open Drain ao : AF Output 28 | ad : AF Open Drain ud : Undefined na : Pin Not Exits 29 | =undefined 30 | > 31 | ```` 32 | 33 | 34 | ## Bug tracker 35 | 36 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 37 | 38 | ## Twitter account 39 | 40 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 41 | 42 | ## Contributing 43 | 44 | 1. Fork it. 45 | 2. Create a branch (`git checkout -b myEspruino`) 46 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 47 | 4. Push to the branch (`git push origin myEspruino`) 48 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 49 | 50 | ## License 51 | 52 | Espruino by Examples < http://git.io/ebe > 53 | 54 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 55 | 56 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 57 | 58 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 59 | 60 | 61 | -------------------------------------------------------------------------------- /list_pins_with_modes/list_pins_with_modes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | List Pins with Modes 21 | by Kay Anar on July 15, 2014 22 | 23 | */ 24 | 25 | var pinStart = [ A0, B0, C0, D0 ]; 26 | var pinNames = [ "A", "B", "C", "D"]; 27 | var pinModes = 28 | { 29 | "input": "in", 30 | "input_pullup": "iu", 31 | "input_pulldown": "id", 32 | "output": "op", 33 | "opendrain": "od", 34 | "af_output": "ao", 35 | "af_opendrain": "ad", 36 | "undefined": "ud" 37 | }; 38 | 39 | print("Pin Modes :"); 40 | print(" 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15"); 41 | 42 | for (var groupIndex = 0; groupIndex < pinStart.length; groupIndex++) 43 | { 44 | var values = pinNames[groupIndex] + " | "; 45 | for (var pinIndex = 0; pinIndex < 16; pinIndex++) 46 | try 47 | { 48 | values += pinModes[getPinMode(pinStart[groupIndex] + pinIndex)] + " | "; 49 | } 50 | catch(exception) 51 | { 52 | values += "na" + " | "; 53 | } 54 | print(" +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+"); 55 | print(values); 56 | } 57 | print(" +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+"); 58 | print("Legend :"); 59 | print(" in : Input iu : Input Pull Up id : Input Pull Down"); 60 | print(" op : Output od : Open Drain ao : AF Output"); 61 | print(" ad : AF Open Drain ud : Undefined na : Pin Not Exits"); -------------------------------------------------------------------------------- /list_pins_with_modes/list_pins_with_modes.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Pin Modes : 9 | 00 01 _ 02 03 04_ 05 06 07 08 09 10 11 12 13 14 15 10 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 11 | A | in | in | in | in | in | in | in | in | in | ao | iu | ud | ud | in | in | in | 12 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 13 | B | in | in | in | in | in | in | in | in | in | in | in | in | in | ud | ud | ud | 14 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 15 | C | in | in | in | in | in | in | in | in | in | in | in | in | in | op | in | in | 16 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 17 | D | in | in | ud | na | na | na | na | na | na | na | na | na | na | na | na | na | 18 | +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ 19 | Legend : 20 | in : Input iu : Input Pull Up id : Input Pull Down 21 | op : Output od : Open Drain ao : AF Output 22 | ad : AF Open Drain ud : Undefined na : Pin Not Exits 23 | =undefined 24 | > -------------------------------------------------------------------------------- /memory_hex_dump/README.md: -------------------------------------------------------------------------------- 1 | # Memory Hex Dump 2 | 3 | **by Kay Anar in July 6, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | Address Hexadecimal Values Ascii Values 15 | -------- -------------------------------------------- --------------- 16 | 0802A0FA 00 BF F8 BC 08 BC 9E 46 70 47 08 07 00 00 14 .¿ø¼.¼.FpG..... 17 | 0802A109 00 00 00 61 AC 01 08 49 AC 01 08 61 AC 01 08 ...a¬..I¬..a¬.. 18 | 0802A118 61 AC 01 08 61 AC 01 08 61 AC 01 08 61 AC 01 a¬..a¬..a¬..a¬. 19 | 0802A127 08 61 AC 01 08 3D AC 01 08 00 A2 4A 04 01 00 .a¬..=¬...¢J... 20 | 0802A136 00 00 EF BE AD DE BE BA FE CA 49 4C 02 08 12 ..ï¾.Þ¾ºþÊIL... 21 | 0802A145 00 00 00 06 4C 02 08 43 00 00 00 FF FF 00 00 ....L..C...ÿÿ.. 22 | 0802A154 01 1A 03 53 00 54 00 4D 00 33 00 32 00 00 00 ...S.T.M.3.2... 23 | 0802A163 00 00 00 00 00 00 00 00 00 00 00 00 00 AB 52 .............«R 24 | 0802A172 02 08 04 00 00 00 85 52 02 08 26 00 00 00 0A .......R..&.... 25 | 0802A181 50 02 08 32 00 00 00 51 00 00 20 1A 00 00 00 P..2...Q.. .... 26 | 0802A190 FF FF 00 00 FF FF FF FF 00 00 00 00 01 02 03 ÿÿ..ÿÿÿÿ....... 27 | 0802A19F 04 01 02 03 04 06 07 08 09 00 C2 01 00 00 00 ..........Â.... 28 | 0802A1AE 08 00 02 04 06 08 15 B8 00 08 A1 69 00 08 29 .......¸..¡i..) 29 | 0802A1BD AC 01 08 25 AC 01 08 C9 AB 01 08 75 AB 01 08 ¬..%¬..É«..u«.. 30 | 0802A1CC 65 AB 01 08 6D 69 00 08 4D 69 00 08 31 AB 01 e«..mi..Mi..1«. 31 | 0802A1DB 08 00 00 00 00 40 00 00 00 FF FF FF FF FF FF .....@...ÿÿÿÿÿÿ 32 | 0802A1EA FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 33 | 0802A1F9 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 34 | =undefined 35 | > 36 | ```` 37 | 38 | 39 | ## Bug tracker 40 | 41 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 42 | 43 | ## Twitter account 44 | 45 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 46 | 47 | ## Contributing 48 | 49 | 1. Fork it. 50 | 2. Create a branch (`git checkout -b myEspruino`) 51 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 52 | 4. Push to the branch (`git push origin myEspruino`) 53 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 54 | 55 | ## License 56 | 57 | Espruino by Examples < http://git.io/ebe > 58 | 59 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 60 | 61 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 62 | 63 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 64 | 65 | 66 | -------------------------------------------------------------------------------- /memory_hex_dump/memory_hex_dump.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Memory Hex Dump 21 | by Kay Anar in July 6, 2014 22 | 23 | This script dumps a memory range as hexadecimal and ascii 24 | 25 | */ 26 | 27 | function hexformat(value, digit) 28 | { 29 | value = value.toString(16).toUpperCase(); 30 | var zeros = digit - value.length; 31 | for(var index = 0; index < zeros; index++) 32 | value = "0" + value; 33 | return(value); 34 | } 35 | 36 | function hexdump(start, end) 37 | { 38 | start -= start % 0xF; 39 | print("Address Hexadecimal Values Ascii Values"); 40 | print("-------- -------------------------------------------- ---------------"); 41 | for(var index = start; index < end ; index += 0xF) 42 | { 43 | var hexout = ""; 44 | var ascout = ""; 45 | for(var offset = 0x0; offset < 0xF; offset++) 46 | { 47 | var value = peek8(index + offset); 48 | hexout += " " + hexformat(value, 2); 49 | if ((value > 31 && value < 128) || (value > 160 && value < 256 && value != 173)) 50 | ascout += String.fromCharCode(value); 51 | else 52 | ascout += "."; 53 | value = null; 54 | } 55 | print(hexformat(index, 8) + hexout + " " + ascout); 56 | hexout = null; 57 | ascout = null; 58 | } 59 | } 60 | 61 | function onInit() 62 | { 63 | hexdump(process.memory().flash_binary_end, process.memory().flash_binary_end + 255); 64 | } 65 | 66 | onInit(); -------------------------------------------------------------------------------- /memory_hex_dump/memory_hex_dump.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Address Hexadecimal Values Ascii Values 9 | -------- -------------------------------------------- --------------- 10 | 0802A0FA 00 BF F8 BC 08 BC 9E 46 70 47 08 07 00 00 14 .¿ø¼.¼.FpG..... 11 | 0802A109 00 00 00 61 AC 01 08 49 AC 01 08 61 AC 01 08 ...a¬..I¬..a¬.. 12 | 0802A118 61 AC 01 08 61 AC 01 08 61 AC 01 08 61 AC 01 a¬..a¬..a¬..a¬. 13 | 0802A127 08 61 AC 01 08 3D AC 01 08 00 A2 4A 04 01 00 .a¬..=¬...¢J... 14 | 0802A136 00 00 EF BE AD DE BE BA FE CA 49 4C 02 08 12 ..ï¾.Þ¾ºþÊIL... 15 | 0802A145 00 00 00 06 4C 02 08 43 00 00 00 FF FF 00 00 ....L..C...ÿÿ.. 16 | 0802A154 01 1A 03 53 00 54 00 4D 00 33 00 32 00 00 00 ...S.T.M.3.2... 17 | 0802A163 00 00 00 00 00 00 00 00 00 00 00 00 00 AB 52 .............«R 18 | 0802A172 02 08 04 00 00 00 85 52 02 08 26 00 00 00 0A .......R..&.... 19 | 0802A181 50 02 08 32 00 00 00 51 00 00 20 1A 00 00 00 P..2...Q.. .... 20 | 0802A190 FF FF 00 00 FF FF FF FF 00 00 00 00 01 02 03 ÿÿ..ÿÿÿÿ....... 21 | 0802A19F 04 01 02 03 04 06 07 08 09 00 C2 01 00 00 00 ..........Â.... 22 | 0802A1AE 08 00 02 04 06 08 15 B8 00 08 A1 69 00 08 29 .......¸..¡i..) 23 | 0802A1BD AC 01 08 25 AC 01 08 C9 AB 01 08 75 AB 01 08 ¬..%¬..É«..u«.. 24 | 0802A1CC 65 AB 01 08 6D 69 00 08 4D 69 00 08 31 AB 01 e«..mi..Mi..1«. 25 | 0802A1DB 08 00 00 00 00 40 00 00 00 FF FF FF FF FF FF .....@...ÿÿÿÿÿÿ 26 | 0802A1EA FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 27 | 0802A1F9 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 28 | =undefined 29 | > -------------------------------------------------------------------------------- /memory_leak/README.md: -------------------------------------------------------------------------------- 1 | # Memory Leak 2 | 3 | **by Kay Anar in July 3, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | =undefined 15 | > 1744 16 | < 1472 17 | > 1465 18 | < 1200 19 | > 1193 20 | < 928 21 | > 921 22 | < 656 23 | > 649 24 | < 384 25 | > 377 26 | < 112 27 | > 105 28 | ERROR: Out of Memory! 29 | WARNING: Truncating string as not enough memory 30 | ERROR: Error processing interval - removing it. 31 | Execution Interrupted during event processing. 32 | at linein function called from system 33 | > 34 | ```` 35 | 36 | 37 | ## Bug tracker 38 | 39 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 40 | 41 | ## Twitter account 42 | 43 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 44 | 45 | ## Contributing 46 | 47 | 1. Fork it. 48 | 2. Create a branch (`git checkout -b myEspruino`) 49 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 50 | 4. Push to the branch (`git push origin myEspruino`) 51 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 52 | 53 | ## License 54 | 55 | Espruino by Examples < http://git.io/ebe > 56 | 57 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 58 | 59 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 60 | 61 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 62 | 63 | 64 | -------------------------------------------------------------------------------- /memory_leak/memory_leak.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Memory Leak 21 | by Kay Anar in July 3, 2014 22 | 23 | This script demonstrates how to leak memory on Espruino board. 24 | 25 | In short : If you have a large object that is used by some closures, 26 | but not by any closures that you need to keep using, just make sure 27 | that the local variable no longer points to it once you're done with it. 28 | 29 | */ 30 | 31 | var myObject = null; 32 | 33 | var leakMemory = function () 34 | { 35 | print(">", process.memory().free); 36 | 37 | var myOldObject = myObject; 38 | 39 | myObject = 40 | { 41 | myString : new Array(1000).join('LEAK'), 42 | myFunction : function () 43 | { 44 | print(myString); 45 | } 46 | }; 47 | 48 | print("<", process.memory().free); 49 | }; 50 | 51 | setInterval(leakMemory, 1000); -------------------------------------------------------------------------------- /memory_leak/memory_leak.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | =undefined 9 | > 1744 10 | < 1472 11 | > 1465 12 | < 1200 13 | > 1193 14 | < 928 15 | > 921 16 | < 656 17 | > 649 18 | < 384 19 | > 377 20 | < 112 21 | > 105 22 | ERROR: Out of Memory! 23 | WARNING: Truncating string as not enough memory 24 | ERROR: Error processing interval - removing it. 25 | Execution Interrupted during event processing. 26 | at linein function called from system 27 | > -------------------------------------------------------------------------------- /morse_pulse_to_letter/README.md: -------------------------------------------------------------------------------- 1 | # Morse Pulse to Letter 2 | 3 | **by Kay Anar in July 11, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | =undefined 15 | S 16 | O 17 | S 18 | > 19 | ```` 20 | 21 | 22 | ## Bug tracker 23 | 24 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 25 | 26 | ## Twitter account 27 | 28 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 29 | 30 | ## Contributing 31 | 32 | 1. Fork it. 33 | 2. Create a branch (`git checkout -b myEspruino`) 34 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 35 | 4. Push to the branch (`git push origin myEspruino`) 36 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 37 | 38 | ## License 39 | 40 | Espruino by Examples < http://git.io/ebe > 41 | 42 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 43 | 44 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 45 | 46 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 47 | 48 | 49 | -------------------------------------------------------------------------------- /morse_pulse_to_letter/morse_pulse_to_letter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Morse Pulse to Letter 21 | by Kay Anar in July 11, 2014 22 | 23 | This script shows how to measure the length of a button pulse. 24 | 25 | */ 26 | 27 | var dash_length = 0.2; 28 | var letter_timeout = 750; 29 | 30 | var morse = 31 | { 32 | ".-" : "A", 33 | "-..." : "B", 34 | "-.-." : "C", 35 | "-.." : "D", 36 | "." : "E", 37 | "..-. " : "F", 38 | "--." : "G", 39 | "...." : "H", 40 | ".." : "I", 41 | ".---" : "J", 42 | "-.-" : "K", 43 | ".-.." : "L", 44 | "--" : "M", 45 | "-." : "N", 46 | "---" : "O", 47 | ".--." : "P", 48 | "--.-" : "Q", 49 | ".-." : "R", 50 | "..." : "S", 51 | "-" : "T", 52 | "..-" : "U", 53 | "...-" : "V", 54 | ".--" : "W", 55 | "-..-" : "X", 56 | "-.--" : "Y", 57 | "--.." : "Z", 58 | "-----" : "0", 59 | ".----" : "1", 60 | "..---" : "2", 61 | "...--" : "3", 62 | "....-" : "4", 63 | "....." : "5", 64 | "-...." : "6", 65 | "--..." : "7", 66 | "---.." : "8", 67 | "----." : "9", 68 | ".-.-.-" : ".", 69 | "--..--" : ",", 70 | "..--.." : "?" 71 | }; 72 | 73 | var input = ""; 74 | var timeout = -1; 75 | 76 | function morsePrint() 77 | { 78 | print(morse[input]); 79 | input = ""; 80 | timeout = -1; 81 | } 82 | 83 | function morseInput(event) 84 | { 85 | input += event.time - event.lastTime < dash_length ? "." : "-"; 86 | 87 | if(timeout != -1) 88 | clearTimeout(timeout); 89 | 90 | timeout = setTimeout(morsePrint, letter_timeout); 91 | } 92 | 93 | setWatch(morseInput, BTN, { repeat:true, edge:"falling" }); -------------------------------------------------------------------------------- /morse_pulse_to_letter/morse_pulse_to_letter.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | =undefined 9 | S 10 | O 11 | S 12 | > -------------------------------------------------------------------------------- /on_board_led_blinker_1/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 1 2 | 3 | **by Kay Anar in July 14, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_1/on_board_led_blinker_1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 1 21 | by Kay Anar in July 14, 2014 22 | 23 | Turns on LED3 for one second, then off for one second, repeatedly. 24 | 25 | */ 26 | 27 | setInterval(function() { digitalWrite(LED3, a = !a); }, 1000); -------------------------------------------------------------------------------- /on_board_led_blinker_10/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 10 2 | 3 | **by Kay Anar in July 17, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_10/on_board_led_blinker_10.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 10 21 | by Kay Anar in July 17, 2014 22 | 23 | */ 24 | 25 | setInterval(function() { digitalWrite([LED1, LED2, LED3], Math.pow(2, a = (a + 1) % 3)); }, 100); -------------------------------------------------------------------------------- /on_board_led_blinker_11/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 11 2 | 3 | **by Kay Anar in June 24, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_11/on_board_led_blinker_11.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 11 21 | by Kay Anar in June 24, 2014 22 | 23 | */ 24 | 25 | setInterval(function() { digitalWrite(LED1, !digitalRead(LED1)); }, 100); 26 | 27 | setInterval(function() { digitalWrite(LED2, !digitalRead(LED2)); }, 200); 28 | 29 | setInterval(function() { digitalWrite(LED3, !digitalRead(LED3)); }, 300); -------------------------------------------------------------------------------- /on_board_led_blinker_12/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 12 2 | 3 | **by Kay Anar in July 12, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_12/on_board_led_blinker_12.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 12 21 | by Kay Anar in July 12, 2014 22 | 23 | */ 24 | 25 | setInterval(function() { digitalWrite(LED1, a=!a); }, 100); 26 | 27 | setInterval(function() { digitalWrite(LED2, b=!b); }, 200); 28 | 29 | setInterval(function() { digitalWrite(LED3, c=!c); }, 300); -------------------------------------------------------------------------------- /on_board_led_blinker_2/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 2 2 | 3 | **by Kay Anar in July 16, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_2/on_board_led_blinker_2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 2 21 | by Kay Anar in July 16, 2014 22 | 23 | Turns on all LEDs for one second, then off for one second, repeatedly. 24 | 25 | */ 26 | 27 | setInterval(function() { digitalWrite([LED1, LED2, LED3], a = !a ? 7 : 0); }, 1000); -------------------------------------------------------------------------------- /on_board_led_blinker_3/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 3 2 | 3 | **by Kay Anar in July 17, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_3/on_board_led_blinker_3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 3 21 | by Kay Anar in July 17, 2014 22 | 23 | Turns on LED3 for one second, then off for one second, repeatedly. 24 | 25 | */ 26 | 27 | setInterval(function() { digitalPulse(LED3, 1, 1000); }, 2000); -------------------------------------------------------------------------------- /on_board_led_blinker_4/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 4 2 | 3 | **by Kay Anar in July 17, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_4/on_board_led_blinker_4.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 4 21 | by Kay Anar in July 17, 2014 22 | 23 | Turns on LED3 for one second, then off for one second, repeatedly. 24 | 25 | */ 26 | 27 | setInterval(function() { digitalWrite(LED3, !digitalRead(LED3)); }, 1000); -------------------------------------------------------------------------------- /on_board_led_blinker_5/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 5 2 | 3 | **by Kay Anar in July 17, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_5/on_board_led_blinker_5.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 5 21 | by Kay Anar in July 17, 2014 22 | 23 | Turns on LED3 for one second, then off for one second, repeatedly. 24 | 25 | */ 26 | 27 | setInterval(function() { LED3.reset(); }, 1000); 28 | setInterval(function() { LED3.set(); }, 2000); 29 | -------------------------------------------------------------------------------- /on_board_led_blinker_6/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 6 2 | 3 | **by Kay Anar in July 18, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_6/on_board_led_blinker_6.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 6 21 | by Kay Anar in July 18, 2014 22 | 23 | */ 24 | 25 | setInterval(function() { digitalWrite([LED1, LED2, LED3], Math.random() > 0.75 ? 7 : 0); }, 50); -------------------------------------------------------------------------------- /on_board_led_blinker_7/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 7 2 | 3 | **by Kay Anar in July 3, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_7/on_board_led_blinker_7.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 7 21 | by Kay Anar in July 3, 2014 22 | 23 | */ 24 | 25 | setInterval(function() { digitalWrite(13 + ((Math.random() * 3) | 0), Math.random() > 0.5); }, 50); -------------------------------------------------------------------------------- /on_board_led_blinker_8/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 8 2 | 3 | **by Kay Anar in July 16, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_8/on_board_led_blinker_8.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 8 21 | by Kay Anar in July 16, 2014 22 | 23 | */ 24 | 25 | setInterval(function() { digitalWrite([LED1, LED2, LED3], a = (a % 4) + 1); }, 100); -------------------------------------------------------------------------------- /on_board_led_blinker_9/README.md: -------------------------------------------------------------------------------- 1 | # On Board LED Blinker 9 2 | 3 | **by Kay Anar in July 16, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /on_board_led_blinker_9/on_board_led_blinker_9.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | On Board LED Blinker 9 21 | by Kay Anar in July 16, 2014 22 | 23 | */ 24 | 25 | setInterval(function() { digitalWrite([LED1, LED2, LED3], Math.random() * 7 | 0); }, 100); -------------------------------------------------------------------------------- /play_a_melody/README.md: -------------------------------------------------------------------------------- 1 | # Play a Melody For Espruino 2 | 3 | **by Kay Anar in June 24, 2014** 4 | 5 | ## Board Setup 6 | ![Board Setup](play_a_melody.png "Board Setup for Play a Melody For Espruino") 7 | 8 | 9 | 10 | ## Bug tracker 11 | 12 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 13 | 14 | ## Twitter account 15 | 16 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 17 | 18 | ## Contributing 19 | 20 | 1. Fork it. 21 | 2. Create a branch (`git checkout -b myEspruino`) 22 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 23 | 4. Push to the branch (`git push origin myEspruino`) 24 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 25 | 26 | ## License 27 | 28 | Espruino by Examples < http://git.io/ebe > 29 | 30 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 31 | 32 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 33 | 34 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 35 | 36 | 37 | -------------------------------------------------------------------------------- /play_a_melody/play_a_melody.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/play_a_melody/play_a_melody.fzz -------------------------------------------------------------------------------- /play_a_melody/play_a_melody.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Play a Melody For Espruino 21 | by Kay Anar in June 24, 2014 22 | 23 | This script shows how to generate notes using analogWrite function. 24 | It plays a little melody you may have heard before. 25 | 26 | It is based on Tom Igoe's Arduino tone example 27 | at http://arduino.cc/en/Tutorial/tone 28 | 29 | */ 30 | 31 | var note_names = [ "B0", "C1", "CS1", "D1", "DS1", "E1", "F1", "FS1", "G1", "GS1", "A1", "AS1", "B1", "C2", "CS2", "D2", "DS2", "E2", "F2", "FS2", "G2", "GS2", "A2", "AS2", "B2", "C3", "CS3", "D3", "DS3", "E3", "F3", "FS3", "G3", "GS3", "A3", "AS3", "B3", "C4", "CS4", "D4", "DS4", "E4", "F4", "FS4", "G4", "GS4", "A4", "AS4", "B4", "C5", "CS5", "D5", "DS5", "E5", "F5", "FS5", "G5", "GS5", "A5", "AS5", "B5", "C6", "CS6", "D6", "DS6", "E6", "F6", "FS6", "G6", "GS6", "A6", "AS6", "B6", "C7", "CS7", "D7", "DS7", "E7", "F7", "FS7", "G7", "GS7", "A7", "AS7", "B7", "C8", "CS8", "D8", "DS8" ]; 32 | 33 | var note_freqs = [ 31, 33, 35, 37, 39, 41, 44, 46, 49, 52, 55, 58, 62, 65, 69, 73, 78, 82, 87, 93, 98, 104, 110, 117, 123, 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247, 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988, 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976, 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951, 4186, 4435, 4699, 4978 ]; 34 | 35 | var melody_notes = [ "C4", "G3", "G3", "A3", "G3", "", "B3", "C4" ]; 36 | 37 | var melody_duration = [ 4, 8, 8, 4, 4, 4, 4, 4 ]; 38 | 39 | var speaker_pin = A10; 40 | 41 | var repeat_melody = true; 42 | 43 | var melodyIndex = 0; 44 | 45 | function playNote() 46 | { 47 | var index = note_names.indexOf(melody_notes[++melodyIndex]); 48 | 49 | if (index == -1) 50 | digitalWrite(speaker_pin, 0); 51 | else 52 | analogWrite(speaker_pin, 0.5, { freq: note_freqs[index] } ); 53 | 54 | if (melodyIndex < melody_notes.length) 55 | { 56 | setTimeout(playNote, 1000 / melody_duration[melodyIndex]); 57 | } 58 | else if (repeat_melody) 59 | { 60 | melodyIndex = 0; 61 | setTimeout(playNote, 2000); 62 | } 63 | } 64 | 65 | setTimeout(playNote, 100); -------------------------------------------------------------------------------- /play_a_melody/play_a_melody.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/play_a_melody/play_a_melody.png -------------------------------------------------------------------------------- /print_function_test/README.md: -------------------------------------------------------------------------------- 1 | # Print Function Test 2 | 3 | **by Kay Anar in July 3, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | --- 15 | null 16 | line 1 17 | Line 2 18 | return 2 19 | tab 20 | pretab posttab 21 | ' 22 | joey's 23 | joez's 24 | " 25 | joe "the ripper" 26 | joez" 27 | bacspace 28 | form eed 29 | 30 | --- 31 | true 32 | true false 33 | true 34 | [true,false,true,true] 35 | --- 36 | 7 37 | 2 5 38 | 3 39 | [3,5,12,-10,0] 40 | --- 41 | 23.23 42 | 532.32 2321.21312100000 43 | 3.14 44 | [232.21312099999,111.010101,-0.0001,0,1.999999] 45 | --- 46 | Hello 47 | Hello world 48 | Joe Doe 49 | [ 50 | "Hello", 51 | "John", 52 | "and", 53 | "Jane", 54 | "Doe" 55 | ] 56 | --- 57 | function () { return("x"); } 58 | function () { return(42); } 59 | --- 60 | Hello false 4 122.23121211000 function () { return(1); } 61 | [ 62 | "Hello", 63 | true,1,3,14, 64 | function () { return(false); } 65 | ] 66 | --- 67 | {"a":1,"b":false} 68 | { 69 | "firstName":"John", 70 | "lastName":"Doe", 71 | "age":50, 72 | "eyeColor":"blue", 73 | "getAge":function () { 74 | this.age++; 75 | return(this.age); 76 | } 77 | } 78 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 79 | =undefined 80 | Uncaught SyntaxError: Got ')' expected EOF 81 | at line 1 col 94 82 | ...", "13", "14", "15", "16", "17"); 83 | ^ 84 | at line 1 col 98 85 | ...13", "14", "15", "16", "17"); 86 | ^ 87 | > 88 | ```` 89 | 90 | 91 | ## Bug tracker 92 | 93 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 94 | 95 | ## Twitter account 96 | 97 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 98 | 99 | ## Contributing 100 | 101 | 1. Fork it. 102 | 2. Create a branch (`git checkout -b myEspruino`) 103 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 104 | 4. Push to the branch (`git push origin myEspruino`) 105 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 106 | 107 | ## License 108 | 109 | Espruino by Examples < http://git.io/ebe > 110 | 111 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 112 | 113 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 114 | 115 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 116 | 117 | 118 | -------------------------------------------------------------------------------- /print_function_test/print_function_test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Print Function Test 21 | by Kay Anar in July 3, 2014 22 | 23 | This script for testing Print function of Espruino 24 | 25 | */ 26 | 27 | var booleanVar = true; 28 | var booleanArr = [ true, false, true, true ]; 29 | 30 | var integerVar = 3; 31 | var integerArr = [ 3, 5, 12, -10, 0]; 32 | 33 | var floatVar = 3.14; 34 | var floatArr = [232.213121, 111.0101010, -0.0001, 0.0, 1.999999]; 35 | 36 | var stringVar = "Joe Doe"; 37 | var stringArr = ["Hello", "John", "and", "Jane", "Doe"]; 38 | 39 | var functionVar = function() { return(42); }; 40 | 41 | var mixedArr = ["Hello", true, 1, 3,14, function() { return(false); }]; 42 | 43 | var objectVar = 44 | { 45 | firstName:"John", 46 | lastName:"Doe", 47 | age:50, 48 | eyeColor:"blue", 49 | getAge:function() 50 | { 51 | this.age++; 52 | return(this.age); 53 | } 54 | }; 55 | 56 | 57 | print("---"); 58 | print(null); 59 | print(); 60 | print(""); 61 | print("\n"); 62 | print("line 1\nLine 2"); 63 | print("\r"); 64 | print("return 1\rreturn 2"); 65 | print("\n\r"); 66 | print("\ttab"); 67 | print("pretab\tposttab"); 68 | print("\'"); 69 | print("joey\'s"); 70 | print("joez's"); 71 | print("\""); 72 | print("joe \"the ripper\""); 73 | print("joez\""); 74 | print("\b"); 75 | print("back\b\space"); 76 | print("\f"); 77 | print("form\f\feed"); 78 | 79 | print(" "); 80 | 81 | print("---"); 82 | print(true); 83 | print(true, false); 84 | print(booleanVar); 85 | print(booleanArr); 86 | 87 | 88 | print("---"); 89 | print(7); 90 | print(2, 5); 91 | print(integerVar); 92 | print(integerArr); 93 | 94 | print("---"); 95 | print(23.23); 96 | print(532.32, 2321.213121); 97 | print(floatVar); 98 | print(floatArr); 99 | 100 | print("---"); 101 | print("Hello"); 102 | print("Hello", "world"); 103 | print(stringVar); 104 | print(stringArr); 105 | 106 | print("---"); 107 | print(function() { return("x"); }); 108 | print(functionVar); 109 | 110 | print("---"); 111 | print("Hello", false, 4, 122.23121211, function() { return(1); }); 112 | print(mixedArr); 113 | 114 | print("---"); 115 | print({a : 1, b : false}); 116 | print(objectVar); 117 | 118 | print("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"); 119 | print("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17"); -------------------------------------------------------------------------------- /print_function_test/print_function_test.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | --- 9 | null 10 | line 1 11 | Line 2 12 | return 2 13 | tab 14 | pretab posttab 15 | ' 16 | joey's 17 | joez's 18 | " 19 | joe "the ripper" 20 | joez" 21 | bacspace 22 | form eed 23 | 24 | --- 25 | true 26 | true false 27 | true 28 | [true,false,true,true] 29 | --- 30 | 7 31 | 2 5 32 | 3 33 | [3,5,12,-10,0] 34 | --- 35 | 23.23 36 | 532.32 2321.21312100000 37 | 3.14 38 | [232.21312099999,111.010101,-0.0001,0,1.999999] 39 | --- 40 | Hello 41 | Hello world 42 | Joe Doe 43 | [ 44 | "Hello", 45 | "John", 46 | "and", 47 | "Jane", 48 | "Doe" 49 | ] 50 | --- 51 | function () { return("x"); } 52 | function () { return(42); } 53 | --- 54 | Hello false 4 122.23121211000 function () { return(1); } 55 | [ 56 | "Hello", 57 | true,1,3,14, 58 | function () { return(false); } 59 | ] 60 | --- 61 | {"a":1,"b":false} 62 | { 63 | "firstName":"John", 64 | "lastName":"Doe", 65 | "age":50, 66 | "eyeColor":"blue", 67 | "getAge":function () { 68 | this.age++; 69 | return(this.age); 70 | } 71 | } 72 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 73 | =undefined 74 | Uncaught SyntaxError: Got ')' expected EOF 75 | at line 1 col 94 76 | ...", "13", "14", "15", "16", "17"); 77 | ^ 78 | at line 1 col 98 79 | ...13", "14", "15", "16", "17"); 80 | ^ 81 | > -------------------------------------------------------------------------------- /reflex_game/README.md: -------------------------------------------------------------------------------- 1 | # Reflex Game 2 | 3 | **by Kay Anar in June, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | Welcome to Reflex Game 15 | The aim of the game to improve your reaction time and reflex, 16 | to score, press the button when the blue light lit. 17 | Good luck ;) 18 | =undefined 19 | Congratulations, you caught the blue light. your new score is 2 20 | Congratulations, you caught the blue light. your new score is 3 21 | Congratulations, you caught the blue light. your new score is 4 22 | Congratulations, you caught the blue light. your new score is 5 23 | Congratulations, you caught the blue light. your new score is 6 24 | Congratulations, you caught the blue light. your new score is 7 25 | Congratulations, you caught the blue light. your new score is 8 26 | Congratulations, you caught the blue light. your new score is 9 27 | Congratulations, you caught the blue light. your new score is 10 28 | Congratulations, you caught the blue light. your new score is 11 29 | Congratulations, you caught the blue light. your new score is 12 30 | Congratulations, you caught the blue light. your new score is 13 31 | Congratulations, you caught the blue light. your new score is 14 32 | Congratulations, you caught the blue light. your new score is 15 33 | Congratulations, you caught the blue light. your new score is 16 34 | Congratulations, you caught the blue light. your new score is 17 35 | Congratulations, you caught the blue light. your new score is 18 36 | Sorry you lost, please reset the board to play again. 37 | > 38 | ```` 39 | 40 | 41 | ## Bug tracker 42 | 43 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 44 | 45 | ## Twitter account 46 | 47 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 48 | 49 | ## Contributing 50 | 51 | 1. Fork it. 52 | 2. Create a branch (`git checkout -b myEspruino`) 53 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 54 | 4. Push to the branch (`git push origin myEspruino`) 55 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 56 | 57 | ## License 58 | 59 | Espruino by Examples < http://git.io/ebe > 60 | 61 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 62 | 63 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 64 | 65 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 66 | 67 | 68 | -------------------------------------------------------------------------------- /reflex_game/reflex_game.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Reflex Game 21 | by Kay Anar in June, 2014 22 | 23 | It is a simple reflex game using default Espruino 1.3 setup, 24 | using 3 LEDs and push button on the board. 25 | 26 | The aim of the game to improve your reaction time and reflex, 27 | to score, press the button when the blue light (LED3) lit. 28 | 29 | */ 30 | 31 | // Define and initialize the variables 32 | // Current level 33 | var level = 0; 34 | // Timer handler 35 | var timer = 0; 36 | // Current light 37 | var light = 0; 38 | // Button watch handler 39 | var button = 0; 40 | 41 | function random_light() 42 | { 43 | // Pick a random value between 0 to 100 44 | var rnd = Math.random() * 100; 45 | // if number between 0 and 39, light up LED1 46 | if (rnd >= 0 && rnd < 40) 47 | light_led(1); 48 | // if number between 40 and 79, light up LED2 49 | else if (rnd >= 40 && rnd < 80) 50 | light_led(2); 51 | // if number between 80 and 100, light up LED3 52 | else 53 | light_led(3); 54 | } 55 | 56 | function light_led(number) 57 | { 58 | // Set current LED number to light variable 59 | light = number; 60 | // If number is 1 set the LED1 to HIGH else set it to LOW 61 | LED1.write(number == 1 ? HIGH : LOW); 62 | // If number is 2 set the LED2 to HIGH else set it to LOW 63 | LED2.write(number == 2 ? HIGH : LOW); 64 | // If number is 3 set the LED3 to HIGH else set it to LOW 65 | LED3.write(number == 3 ? HIGH : LOW); 66 | } 67 | 68 | function button_down() 69 | { 70 | // Clear timer interval 71 | clearInterval(timer); 72 | // If LED3 is lit, user wins 73 | if (light == 3) 74 | { 75 | // Call the function random_light repreatedly starting 1000 in milliseconds, 76 | // but 50 milliseconds less every level 77 | timer = setInterval(random_light, 1000 - (++level * 50)); 78 | // Print current game level 79 | print('Congratulations, you caught the blue light. your new score is ' + (level + 1)); 80 | } 81 | // User loses, if LED3 is not lit 82 | else 83 | { 84 | // Clear the watch, so board doesn't listen to button anymore 85 | clearWatch(button); 86 | // Call the function anonymous function repeatedly every 1000 in milliseconds. 87 | // to blink the red (LED1) 88 | timer = setInterval(function() { light_led(light == 0); }, 1000); 89 | // Print end of game message 90 | print('Sorry you lost, please reset the board to play again.'); 91 | } 92 | } 93 | 94 | function onInit() 95 | { 96 | // Print game introduction strings to the console 97 | print('Welcome to Reflex Game'); 98 | print('The aim of the game to improve your reaction time and reflex,'); 99 | print('to score, press the button when the blue light lit.'); 100 | print('Good luck ;)'); 101 | 102 | level = 0; 103 | // Call the function 'button_down' when the button pressed 104 | button = setWatch(button_down, BTN, { repeat:true, edge:"falling"}); 105 | 106 | // Call the function random_light repeatedly every 1000 in milliseconds. 107 | timer = setInterval(random_light, 1000); 108 | } 109 | 110 | onInit(); -------------------------------------------------------------------------------- /reflex_game/reflex_game.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Welcome to Reflex Game 9 | The aim of the game to improve your reaction time and reflex, 10 | to score, press the button when the blue light lit. 11 | Good luck ;) 12 | =undefined 13 | Congratulations, you caught the blue light. your new score is 2 14 | Congratulations, you caught the blue light. your new score is 3 15 | Congratulations, you caught the blue light. your new score is 4 16 | Congratulations, you caught the blue light. your new score is 5 17 | Congratulations, you caught the blue light. your new score is 6 18 | Congratulations, you caught the blue light. your new score is 7 19 | Congratulations, you caught the blue light. your new score is 8 20 | Congratulations, you caught the blue light. your new score is 9 21 | Congratulations, you caught the blue light. your new score is 10 22 | Congratulations, you caught the blue light. your new score is 11 23 | Congratulations, you caught the blue light. your new score is 12 24 | Congratulations, you caught the blue light. your new score is 13 25 | Congratulations, you caught the blue light. your new score is 14 26 | Congratulations, you caught the blue light. your new score is 15 27 | Congratulations, you caught the blue light. your new score is 16 28 | Congratulations, you caught the blue light. your new score is 17 29 | Congratulations, you caught the blue light. your new score is 18 30 | Sorry you lost, please reset the board to play again. 31 | > -------------------------------------------------------------------------------- /scripts/README-FOOTER.md: -------------------------------------------------------------------------------- 1 | 2 | ## Bug tracker 3 | 4 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 5 | 6 | ## Twitter account 7 | 8 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 9 | 10 | ## Contributing 11 | 12 | 1. Fork it. 13 | 2. Create a branch (`git checkout -b myEspruino`) 14 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 15 | 4. Push to the branch (`git push origin myEspruino`) 16 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 17 | 18 | ## License 19 | 20 | Espruino by Examples < http://git.io/ebe > 21 | 22 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 23 | 24 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 25 | 26 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 27 | 28 | 29 | -------------------------------------------------------------------------------- /scripts/README-HEADER.md: -------------------------------------------------------------------------------- 1 | # Espruino by Examples 2 | 3 | 4 | -------------------------------------------------------------------------------- /scripts/copyright-notice.txt: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | -------------------------------------------------------------------------------- /scripts/generateRootReadme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | searchWordBoundary() 4 | { 5 | for filename in $(find . -iname "*.js" -exec grep -l -e "\b$1\b" {} \; ); do 6 | if [ "$header" != "" ] 7 | then 8 | echo "" >> README.md 9 | echo "* $header" >> README.md 10 | header="" 11 | fi 12 | title=$(head -n 20 $filename | tail -1) 13 | directory=$(dirname $filename) 14 | echo " * [$title]($directory)" >> README.md 15 | done 16 | } 17 | 18 | functionHeader() 19 | { 20 | header=$1 21 | } 22 | 23 | cat scripts/README-HEADER.md > README.md 24 | 25 | echo "### Globals" >> README.md 26 | echo "" >> README.md 27 | 28 | functionHeader "variable HIGH" 29 | searchWordBoundary HIGH 30 | 31 | functionHeader "variable Infinity" 32 | searchWordBoundary Infinity 33 | 34 | functionHeader "variable LOW" 35 | searchWordBoundary LOW 36 | 37 | functionHeader "variable NaN" 38 | searchWordBoundary NaN 39 | 40 | functionHeader "function analogRead(pin)" 41 | searchWordBoundary analogRead 42 | 43 | functionHeader "function analogWrite(pin, value, options)" 44 | searchWordBoundary analogWrite 45 | 46 | functionHeader "variable arguments" 47 | searchWordBoundary arguments 48 | 49 | functionHeader "function atob(binaryData)" 50 | searchWordBoundary atob 51 | 52 | functionHeader "function btoa(binaryData)" 53 | searchWordBoundary btoa 54 | 55 | functionHeader "function changeInterval(id, time)" 56 | searchWordBoundary changeInterval 57 | 58 | functionHeader "function clearInterval(id)" 59 | searchWordBoundary clearInterval 60 | 61 | functionHeader "function clearTimeout(id)" 62 | searchWordBoundary clearTimeout 63 | 64 | functionHeader "function clearWatch(id)" 65 | searchWordBoundary clearWatch 66 | 67 | functionHeader "function digitalPulse(pin, value, time)" 68 | searchWordBoundary digitalPulse 69 | 70 | functionHeader "function digitalRead(pin)" 71 | searchWordBoundary digitalRead 72 | 73 | functionHeader "function digitalWrite(pin, value)" 74 | searchWordBoundary digitalWrite 75 | 76 | functionHeader "function dump()" 77 | searchWordBoundary dump 78 | 79 | functionHeader "function echo(echoOn)" 80 | searchWordBoundary echo 81 | 82 | functionHeader "function edit(funcName)" 83 | searchWordBoundary edit 84 | 85 | functionHeader "function eval(code)" 86 | searchWordBoundary eval 87 | 88 | functionHeader "function getPinMode(pin)" 89 | searchWordBoundary getPinMode 90 | 91 | functionHeader "function getSerial()" 92 | searchWordBoundary getSerial 93 | 94 | functionHeader "function getTime()" 95 | searchWordBoundary getTime 96 | 97 | functionHeader "function isNaN(x)" 98 | searchWordBoundary isNaN 99 | 100 | functionHeader "function load()" 101 | searchWordBoundary load 102 | 103 | functionHeader "function parseFloat(string)" 104 | searchWordBoundary parseFloat 105 | 106 | functionHeader "function parseInt(string, radix)" 107 | searchWordBoundary parseInt 108 | 109 | functionHeader "function peek16(addr)" 110 | searchWordBoundary peek16 111 | 112 | functionHeader "function peek32(addr)" 113 | searchWordBoundary peek32 114 | 115 | functionHeader "function peek8(addr)" 116 | searchWordBoundary peek8 117 | 118 | functionHeader "function pinMode(pin, mode)" 119 | searchWordBoundary pinMode 120 | 121 | functionHeader "function poke16(addr, value)" 122 | searchWordBoundary poke16 123 | 124 | functionHeader "function poke32(addr, value)" 125 | searchWordBoundary poke32 126 | 127 | functionHeader "function poke8(addr, value)" 128 | searchWordBoundary poke8 129 | 130 | functionHeader "function print(text, ...)" 131 | searchWordBoundary print 132 | 133 | functionHeader "function require(moduleName)" 134 | searchWordBoundary require 135 | 136 | functionHeader "function reset()" 137 | searchWordBoundary reset 138 | 139 | functionHeader "function save()" 140 | searchWordBoundary save 141 | 142 | functionHeader "function setBusyIndicator(pin)" 143 | searchWordBoundary setBusyIndicator 144 | 145 | functionHeader "function setDeepSleep(sleep)" 146 | searchWordBoundary setDeepSleep 147 | 148 | functionHeader "function setInterval(function, timeout)" 149 | searchWordBoundary setInterval 150 | 151 | functionHeader "function setSleepIndicator(pin)" 152 | searchWordBoundary setSleepIndicator 153 | 154 | functionHeader "function setTimeout(function, timeout)" 155 | searchWordBoundary setTimeout 156 | 157 | functionHeader "function setWatch(function, pin, options)" 158 | searchWordBoundary setWatch 159 | 160 | functionHeader "function trace(root)" 161 | searchWordBoundary trace 162 | 163 | cat scripts/README-FOOTER.md >> README.md 164 | -------------------------------------------------------------------------------- /scripts/generateSubReadme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for directory in $(find . -type d | grep -v "./.git" | grep -v "./scripts"); do 4 | if [ "$directory" != "." ] 5 | then 6 | name=$(basename $directory) 7 | if [ -e "$directory/$name.js" ] 8 | then 9 | title=$(head -n 20 $directory/$name.js | tail -1) 10 | echo "# $title" > $directory/README.md 11 | echo "" >> $directory/README.md 12 | author=$(head -n 21 $directory/$name.js | tail -1) 13 | echo "**$author**" >> $directory/README.md 14 | echo "" >> $directory/README.md 15 | if [ -e "$directory/$name.md" ] 16 | then 17 | cat $directory/$name.md >> $directory/README.md 18 | echo "" >> $directory/README.md 19 | echo "" >> $directory/README.md 20 | fi 21 | if [ -e "$directory/$name.png" ] 22 | then 23 | echo "## Board Setup" >> $directory/README.md 24 | echo "![Board Setup]($name.png \"Board Setup for $title\")" >> $directory/README.md 25 | echo "" >> $directory/README.md 26 | echo "" >> $directory/README.md 27 | fi 28 | if [ -e "$directory/$name.txt" ] 29 | then 30 | echo "## Sample Output" >> $directory/README.md 31 | echo "\`\`\`\`" >> $directory/README.md 32 | cat $directory/$name.txt >> $directory/README.md 33 | echo "" >> $directory/README.md 34 | echo "\`\`\`\`" >> $directory/README.md 35 | echo "" >> $directory/README.md 36 | fi 37 | cat scripts/README-FOOTER.md >> $directory/README.md 38 | fi 39 | fi 40 | done 41 | -------------------------------------------------------------------------------- /scripts/updateCopyrightNotice.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for filename in $(find . -iname "*.js" ); do 4 | cat scripts/copyright-notice.txt > $filename.tmp 5 | firstLine=$(head -n 1 $filename) 6 | if [ "$firstLine" == "/**" ] 7 | then 8 | tail +18 $filename >> $filename.tmp 9 | else 10 | cat $filename >> $filename.tmp 11 | fi 12 | mv -f $filename.tmp $filename 13 | done 14 | -------------------------------------------------------------------------------- /servo-object/README.md: -------------------------------------------------------------------------------- 1 | # Servo Object 2 | 3 | **by Kay Anar in July 13, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67_Copyright 2014 G.Williams 13 | >echo(0); 14 | onMoveStart 15 | onMoveEnd 16 | =undefined 17 | > 18 | ```` 19 | 20 | 21 | ## Bug tracker 22 | 23 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 24 | 25 | ## Twitter account 26 | 27 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 28 | 29 | ## Contributing 30 | 31 | 1. Fork it. 32 | 2. Create a branch (`git checkout -b myEspruino`) 33 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 34 | 4. Push to the branch (`git push origin myEspruino`) 35 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 36 | 37 | ## License 38 | 39 | Espruino by Examples < http://git.io/ebe > 40 | 41 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 42 | 43 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 44 | 45 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 46 | 47 | 48 | -------------------------------------------------------------------------------- /servo-object/servo-object.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Servo Object 21 | by Kay Anar in July 13, 2014 22 | 23 | */ 24 | 25 | var Servo = { 26 | "_minPulse" : 0.1, 27 | "_maxPulse" : 2.3, 28 | "connect" : function(servoPin, feedbackPin) 29 | { 30 | if(typeof servoPin == "number") 31 | this.setServoPin(servoPin); 32 | 33 | if(typeof feedbackPin == "number") 34 | this.setFeedbackPin(feedbackPin); 35 | 36 | return(this); 37 | }, 38 | "onMoveStart" : function() 39 | { 40 | print("onMoveStart"); 41 | }, 42 | "setMoveStart" : function(moveStart) 43 | { 44 | if(typeof moveStart == "function") 45 | this.onMoveStart = moveStart; 46 | return(this); 47 | }, 48 | "onMoveEnd" : function() 49 | { 50 | print("onMoveEnd"); 51 | }, 52 | "setMoveEnd" : function(moveEnd) 53 | { 54 | if(typeof moveEnd == "function") 55 | this.onMoveEnd = moveEnd; 56 | return(this); 57 | }, 58 | "setPosition" : function(position, time) 59 | { 60 | if (typeof time != "number" || time < 500) 61 | time = 500; 62 | 63 | if (typeof this._position != "number") 64 | this._position = this._minPulse; 65 | 66 | this._requestedPostion = position; 67 | this._stepAmount = (this._requestedPostion - this._position) / (time / 25); 68 | 69 | this.onMoveStart(); 70 | 71 | var servoObj = this; 72 | servoObj._interval = setInterval(function() 73 | { 74 | servoObj._position += servoObj._stepAmount; 75 | if ((servoObj._stepAmount > 0 && (servoObj._position >= servoObj._requestedPostion || servoObj._position >= servoObj._maxPulse)) || (servoObj._stepAmount < 0 && (servoObj._position <= servoObj._requestedPostion || servoObj._position <= servoObj._minPulse))) 76 | { 77 | clearInterval(servoObj._interval); 78 | delete servoObj._interval; 79 | delete servoObj._requestedPostion; 80 | delete this._stepAmount; 81 | servoObj.onMoveEnd(); 82 | servoObj = null; 83 | } 84 | else 85 | { 86 | digitalPulse(servoObj._servoPin, 1, E.clip(servoObj._position, servoObj._minPulse, servoObj._maxPulse)); 87 | } 88 | }, 25); 89 | return(this); 90 | }, 91 | "getPosition" : function() 92 | { 93 | return(_position); 94 | }, 95 | "setServoPin" : function(servoPin) 96 | { 97 | this._servoPin = servoPin; 98 | return(this); 99 | }, 100 | "getServoPin" : function() 101 | { 102 | return(this._servoPin); 103 | }, 104 | "setFeedbackPin" : function(feedbackPin) 105 | { 106 | this._feedbackPin = feedbackPin; 107 | return(this); 108 | }, 109 | "getFeedbackPin" : function() 110 | { 111 | return(this._feedbackPin); 112 | }, 113 | "getFeedbackValue" : function() 114 | { 115 | if (this._feedbackPin !== undefined) 116 | return(analogRead(this._feedbackPin)); 117 | }, 118 | "setMinPulse" : function(minPulse) 119 | { 120 | if(typeof minPulse == "number") 121 | this._minPulse = minPulse; 122 | return(this); 123 | }, 124 | "getMinPulse" : function() 125 | { 126 | return(this._minPulse); 127 | }, 128 | "setMaxPulse" : function(maxPulse) 129 | { 130 | if(typeof maxPulse == "number") 131 | this._maxPulse = maxPulse; 132 | return(this); 133 | }, 134 | "getMaxPulse" : function() 135 | { 136 | return(this._maxPulse); 137 | } 138 | }; 139 | 140 | Servo.connect(C5, C4); 141 | 142 | //print(Servo.getServoPin()); 143 | Servo.setPosition(0); 144 | Servo.setMoveEnd(function() { Servo.setPosition(Servo.setMinPulse(), 5000); }); 145 | //Servo.setPosition(Servo.setMaxPulse(), 5000); 146 | //Servo.setMoveEnd(function() { Servo.setPosition(Servo.setMinPulse(), 5000); }); -------------------------------------------------------------------------------- /servo-object/servo-object.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67_Copyright 2014 G.Williams 7 | >echo(0); 8 | onMoveStart 9 | onMoveEnd 10 | =undefined 11 | > -------------------------------------------------------------------------------- /text_to_morse_audio_1/README.md: -------------------------------------------------------------------------------- 1 | # Text to Morse Audio 1 2 | 3 | **by Kay Anar in July 13, 2014** 4 | 5 | ## Board Setup 6 | ![Board Setup](text_to_morse_audio_1.png "Board Setup for Text to Morse Audio 1") 7 | 8 | 9 | ## Sample Output 10 | ```` 11 | _____ _ 12 | | __|___ ___ ___ _ _|_|___ ___ 13 | | __|_ -| . | _| | | | | . | 14 | |_____|___| _|_| |___|_|_|_|___| 15 | |_| http://espruino.com 16 | 1v67 Copyright 2014 G.Williams 17 | >echo(0); 18 | Available commands : 19 | play("message"); // Plays your message in morse code 20 | stop(); // Stops current playing morse code message 21 | repeat(); // Toggles repeat playing 22 | =undefined 23 | >play("SOS"); 24 | Playing ... --- ... 25 | =undefined 26 | > 27 | ```` 28 | 29 | 30 | ## Bug tracker 31 | 32 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 33 | 34 | ## Twitter account 35 | 36 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 37 | 38 | ## Contributing 39 | 40 | 1. Fork it. 41 | 2. Create a branch (`git checkout -b myEspruino`) 42 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 43 | 4. Push to the branch (`git push origin myEspruino`) 44 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 45 | 46 | ## License 47 | 48 | Espruino by Examples < http://git.io/ebe > 49 | 50 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 51 | 52 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 53 | 54 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 55 | 56 | 57 | -------------------------------------------------------------------------------- /text_to_morse_audio_1/text_to_morse_audio_1.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/text_to_morse_audio_1/text_to_morse_audio_1.fzz -------------------------------------------------------------------------------- /text_to_morse_audio_1/text_to_morse_audio_1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Text to Morse Audio 1 21 | by Kay Anar in July 13, 2014 22 | 23 | */ 24 | 25 | var morse_codes = 26 | { 27 | "A" : ".-", 28 | "B" : "-...", 29 | "C" : "-.-.", 30 | "D" : "-..", 31 | "E" : ".", 32 | "F" : "..-.", 33 | "G" : "--.", 34 | "H" : "....", 35 | "I" : "..", 36 | "J" : ".---", 37 | "K" : "-.-", 38 | "L" : ".-..", 39 | "M" : "--", 40 | "N" : "-.", 41 | "O" : "---", 42 | "P" : ".--.", 43 | "Q" : "--.-", 44 | "R" : ".-.", 45 | "S" : "...", 46 | "T" : "-", 47 | "U" : "..-", 48 | "V" : "...-", 49 | "W" : ".--", 50 | "X" : "-..-", 51 | "Y" : "-.--", 52 | "Z" : "--..", 53 | "0" : "-----", 54 | "1" : ".----", 55 | "2" : "..---", 56 | "3" : "...--", 57 | "4" : "....-", 58 | "5" : ".....", 59 | "6" : "-....", 60 | "7" : "--...", 61 | "8" : "---..", 62 | "9" : "----.", 63 | "." : ".-.-.-", 64 | "," : "--..--", 65 | "?" : "..--.." 66 | }; 67 | 68 | var morse_message = ""; 69 | 70 | var speaker_pin = A10; 71 | 72 | var repeat_play = false; 73 | 74 | var charIndex = -1; 75 | 76 | function _silence() 77 | { 78 | digitalWrite(speaker_pin, 0); 79 | setTimeout(_playBeep, 150); 80 | } 81 | 82 | function _playBeep() 83 | { 84 | charIndex++; 85 | if (charIndex >= morse_message.length) 86 | if (repeat_play) 87 | charIndex = 0; 88 | else 89 | return; 90 | var char2play = morse_message.charAt(charIndex); 91 | 92 | if (char2play == " ") 93 | digitalWrite(speaker_pin, 0); 94 | else 95 | analogWrite(speaker_pin, 0.5, { freq: 800 } ); 96 | 97 | setTimeout(_silence, char2play == "." ? 100 : 300); 98 | } 99 | 100 | function play(message) 101 | { 102 | morse_message = ""; 103 | for(var index = 0; index < message.length; index++) 104 | { 105 | var code = morse_codes[message.charAt(index).toUpperCase()]; 106 | if (typeof code != "undefined") 107 | morse_message += code + " "; 108 | } 109 | charIndex = -1; 110 | print("Playing", morse_message); 111 | setTimeout(_playBeep, 100); 112 | } 113 | 114 | function stop() 115 | { 116 | repeat_play = false; 117 | charIndex = morse_message.length; 118 | print("Stopped"); 119 | } 120 | 121 | function repeat() 122 | { 123 | repeat_play = !repeat_play; 124 | print ("Repeat", repeat_play); 125 | } 126 | 127 | function onInit() 128 | { 129 | print("Available commands : "); 130 | print("play(\"message\");", "// Plays your message in morse code"); 131 | print("stop();", "// Stops current playing morse code message"); 132 | print("repeat();", "// Toggles repeat playing"); 133 | } 134 | 135 | onInit(); -------------------------------------------------------------------------------- /text_to_morse_audio_1/text_to_morse_audio_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/text_to_morse_audio_1/text_to_morse_audio_1.png -------------------------------------------------------------------------------- /text_to_morse_audio_1/text_to_morse_audio_1.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Available commands : 9 | play("message"); // Plays your message in morse code 10 | stop(); // Stops current playing morse code message 11 | repeat(); // Toggles repeat playing 12 | =undefined 13 | >play("SOS"); 14 | Playing ... --- ... 15 | =undefined 16 | > -------------------------------------------------------------------------------- /text_to_morse_audio_2/README.md: -------------------------------------------------------------------------------- 1 | # Text to Morse Audio 2 2 | 3 | **by Kay Anar in July 20, 2014** 4 | 5 | ## Board Setup 6 | ![Board Setup](text_to_morse_audio_2.png "Board Setup for Text to Morse Audio 2") 7 | 8 | 9 | ## Sample Output 10 | ```` 11 | _____ _ 12 | | __|___ ___ ___ _ _|_|___ ___ 13 | | __|_ -| . | _| | | | | . | 14 | |_____|___| _|_| |___|_|_|_|___| 15 | |_| http://espruino.com 16 | 1v67 Copyright 2014 G.Williams 17 | >echo(0); 18 | Available commands : 19 | play("message"); // Plays your message in morse code 20 | stop(); // Stops current playing morse code message 21 | repeat(); // Toggles repeat playing 22 | =undefined 23 | >play("SOS"); 24 | Playing ... --- ... 25 | =undefined 26 | > 27 | ```` 28 | 29 | 30 | ## Bug tracker 31 | 32 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 33 | 34 | ## Twitter account 35 | 36 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 37 | 38 | ## Contributing 39 | 40 | 1. Fork it. 41 | 2. Create a branch (`git checkout -b myEspruino`) 42 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 43 | 4. Push to the branch (`git push origin myEspruino`) 44 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 45 | 46 | ## License 47 | 48 | Espruino by Examples < http://git.io/ebe > 49 | 50 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 51 | 52 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 53 | 54 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 55 | 56 | 57 | -------------------------------------------------------------------------------- /text_to_morse_audio_2/text_to_morse_audio_2.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/text_to_morse_audio_2/text_to_morse_audio_2.fzz -------------------------------------------------------------------------------- /text_to_morse_audio_2/text_to_morse_audio_2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Text to Morse Audio 2 21 | by Kay Anar in July 20, 2014 22 | 23 | This code uses binary tree to find mode codes; 24 | 25 | T <---------- DAHs MORSE DITs ..........> E 26 | / \ / \ 27 | / \ / \ 28 | / \ / \ 29 | / \ / \ 30 | / \ / \ 31 | / \ / \ 32 | / \ / \ 33 | / \ / \ 34 | / \ / \ 35 | / \ / \ 36 | / \ / \ 37 | M N A I 38 | / \ / \ / \ / \ 39 | / \ / \ / \ / \ 40 | / \ / \ / \ / \ 41 | / \ / \ / \ / \ 42 | / \ / \ / \ / \ 43 | O G K D W R U S 44 | / \ / \ / \ / \ / \ / \ / \ / \ 45 | / \ / \ / \ / \ / \ / \ / \ / \ 46 | × × Q Z Y C X B J P × L × F V H 47 | / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ 48 | 0 9 8 × × × 7 × × × × × × × 6 1 × × × × × × × 2 × × × 3 × 4 5 49 | 50 | */ 51 | 52 | var morse_message = ""; 53 | 54 | var speaker_pin = A10; 55 | 56 | var repeat_play = false; 57 | 58 | var charIndex = -1; 59 | 60 | function text2Morse(text) 61 | { 62 | var morse = ""; 63 | 64 | text = text.toLowerCase(); 65 | 66 | for(var index in text) 67 | { 68 | charOffset = " etinamsdrgukwohblzfcp×vx×q×yj×56×7×××8×××××××94×××××××3×××2×10".indexOf(text[index]); 69 | while(charOffset > 0) 70 | { 71 | morse += "-."[charOffset--&1]; 72 | charOffset = charOffset / 2 | 0; 73 | } 74 | morse += " "; 75 | } 76 | return(morse); 77 | } 78 | 79 | function beep(time) 80 | { 81 | analogWrite(speaker_pin, 0.5, { freq : 800 } ); 82 | setTimeout(function() { digitalWrite(speaker_pin, 0); }, time); 83 | } 84 | 85 | function _playBeep() 86 | { 87 | charIndex++; 88 | if (charIndex >= morse_message.length) 89 | if (repeat_play) 90 | charIndex = 0; 91 | else 92 | return; 93 | 94 | var char2play = morse_message.charAt(charIndex); 95 | 96 | var time = morse_message.charAt(charIndex) == "." ? 100 : 300; 97 | 98 | if (char2play != " ") 99 | beep(time); 100 | 101 | setTimeout(_playBeep, time + 150); 102 | } 103 | 104 | function play(message) 105 | { 106 | morse_message = text2Morse(message); 107 | charIndex = -1; 108 | print("Playing", morse_message); 109 | setTimeout(_playBeep, 100); 110 | } 111 | 112 | function stop() 113 | { 114 | repeat_play = false; 115 | charIndex = morse_message.length; 116 | print("Stopped"); 117 | } 118 | 119 | function repeat() 120 | { 121 | repeat_play = !repeat_play; 122 | print ("Repeat", repeat_play); 123 | } 124 | 125 | function onInit() 126 | { 127 | print("Available commands : "); 128 | print("play(\"message\");", "// Plays your message in morse code"); 129 | print("stop();", "// Stops current playing morse code message"); 130 | print("repeat();", "// Toggles repeat playing"); 131 | } 132 | 133 | onInit(); -------------------------------------------------------------------------------- /text_to_morse_audio_2/text_to_morse_audio_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anars/Espruino/bc1b546008350d8f9cbc28ae9d1c8991ec9c0cfb/text_to_morse_audio_2/text_to_morse_audio_2.png -------------------------------------------------------------------------------- /text_to_morse_audio_2/text_to_morse_audio_2.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | Available commands : 9 | play("message"); // Plays your message in morse code 10 | stop(); // Stops current playing morse code message 11 | repeat(); // Toggles repeat playing 12 | =undefined 13 | >play("SOS"); 14 | Playing ... --- ... 15 | =undefined 16 | > -------------------------------------------------------------------------------- /toggle_button_object/README.md: -------------------------------------------------------------------------------- 1 | # Toggle Button Object 2 | 3 | **by Kay Anar in July 19, 2014** 4 | 5 | 6 | ## Bug tracker 7 | 8 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 9 | 10 | ## Twitter account 11 | 12 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 13 | 14 | ## Contributing 15 | 16 | 1. Fork it. 17 | 2. Create a branch (`git checkout -b myEspruino`) 18 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 19 | 4. Push to the branch (`git push origin myEspruino`) 20 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 21 | 22 | ## License 23 | 24 | Espruino by Examples < http://git.io/ebe > 25 | 26 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 27 | 28 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 31 | 32 | 33 | -------------------------------------------------------------------------------- /toggle_button_object/toggle_button_object.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | Toggle Button Object 21 | by Kay Anar in July 19, 2014 22 | 23 | */ 24 | var ToggleButton = function(_pin, _action) 25 | { 26 | var _value = false; 27 | 28 | this.getValue = function() 29 | { 30 | return(_value); 31 | }; 32 | 33 | this.getPin = function() 34 | { 35 | return(_pin); 36 | }; 37 | 38 | this.setPin = function(newPin) 39 | { 40 | if(typeof newPin == "number") 41 | { 42 | _pin = newPin; 43 | clearWatch(_id); 44 | _id = setWatch(watchAction, _pin, { repeat:true, edge:"rising", debounce:50 }); 45 | } 46 | }; 47 | 48 | this.setAction = function(newAction) 49 | { 50 | if(typeof newAction == "function") 51 | _action = newAction; 52 | }; 53 | 54 | var watchAction = function() 55 | { 56 | _value = !_value; 57 | if(typeof _action == "function") 58 | _action(_value); 59 | }; 60 | 61 | var _id = setWatch(watchAction, _pin, { repeat:true, edge:"rising", debounce:50 }); 62 | 63 | }; 64 | 65 | var tObj = new ToggleButton(BTN, function(value) { digitalWrite(LED3, value); }); 66 | print(wObj); -------------------------------------------------------------------------------- /xor_string/README.md: -------------------------------------------------------------------------------- 1 | # XOR String 2 | 3 | **by Kay Anar in July 27, 2014** 4 | 5 | ## Sample Output 6 | ```` 7 | _____ _ 8 | | __|___ ___ ___ _ _|_|___ ___ 9 | | __|_ -| . | _| | | | | . | 10 | |_____|___| _|_| |___|_|_|_|___| 11 | |_| http://espruino.com 12 | 1v67 Copyright 2014 G.Williams 13 | >echo(0); 14 | p (70) XOR 5 (35) = (45) E 15 | a (61) XOR 1 (31) = (50) P 16 | s (73) XOR 3 (33) = (40) @ 17 | s (73) XOR 5 (35) = (46) F 18 | w (77) XOR 1 (31) = (46) F 19 | o (6f) XOR 3 (33) = (5c) \ 20 | r (72) XOR 5 (35) = (47) G 21 | d (64) XOR 1 (31) = (55) U 22 | =undefined 23 | > 24 | ```` 25 | 26 | 27 | ## Bug tracker 28 | 29 | Have a bug? Please create an [issue](https://github.com/anars/Espruino/issues) here on GitHub! 30 | 31 | ## Twitter account 32 | 33 | Keep up to date on announcements and more by following Anar Software LLC on Twitter, [@AnarSoft](http://twitter.com/AnarSoft). 34 | 35 | ## Contributing 36 | 37 | 1. Fork it. 38 | 2. Create a branch (`git checkout -b myEspruino`) 39 | 3. Commit your changes (`git commit -am "Added New Espruino Sample"`) 40 | 4. Push to the branch (`git push origin myEspruino`) 41 | 5. Create an [issue](https://github.com/anars/Espruino/issues) with a link to your branch 42 | 43 | ## License 44 | 45 | Espruino by Examples < http://git.io/ebe > 46 | 47 | Copyright (c) 2014 Anar Software LLC. < http://anars.com > 48 | 49 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 50 | 51 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/gpl.html 52 | 53 | 54 | -------------------------------------------------------------------------------- /xor_string/xor_string.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Espruino by Examples < http://git.io/ebe > 3 | * 4 | * Copyright (c) 2014 Anar Software LLC. < http://anars.com > 5 | * 6 | * This program is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software 8 | * Foundation, either version 3 of the License, or (at your option) any later 9 | * version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along with 16 | * this program. If not, see < http://www.gnu.org/licenses/ > 17 | */ 18 | /* 19 | 20 | XOR String 21 | by Kay Anar in July 27, 2014 22 | 23 | This function does Bitwise XOR on strings 24 | 25 | */ 26 | 27 | function xorString(text, seed) 28 | { 29 | var result = ""; 30 | for(var index = 0; index < text.length; index++) 31 | result += String.fromCharCode(text.charCodeAt(index) ^ seed.charCodeAt(index % seed.length)); 32 | return(result); 33 | } 34 | 35 | var text = "password"; 36 | var seed = "" + (new Date()).getMilliseconds(); 37 | var xored = xorString(text, seed); 38 | 39 | for(var index = 0; index < xored.length; index++) 40 | print(text.charAt(index), 41 | "(" + text.charCodeAt(index).toString(16) + ")" , 42 | "XOR", seed.charAt(index % seed.length), 43 | "(" + seed.charCodeAt(index % seed.length).toString(16) + ")" , 44 | "=", 45 | "(" + xored.charCodeAt(index).toString(16) + ")", 46 | xored.charAt(index)); -------------------------------------------------------------------------------- /xor_string/xor_string.txt: -------------------------------------------------------------------------------- 1 | _____ _ 2 | | __|___ ___ ___ _ _|_|___ ___ 3 | | __|_ -| . | _| | | | | . | 4 | |_____|___| _|_| |___|_|_|_|___| 5 | |_| http://espruino.com 6 | 1v67 Copyright 2014 G.Williams 7 | >echo(0); 8 | p (70) XOR 5 (35) = (45) E 9 | a (61) XOR 1 (31) = (50) P 10 | s (73) XOR 3 (33) = (40) @ 11 | s (73) XOR 5 (35) = (46) F 12 | w (77) XOR 1 (31) = (46) F 13 | o (6f) XOR 3 (33) = (5c) \ 14 | r (72) XOR 5 (35) = (47) G 15 | d (64) XOR 1 (31) = (55) U 16 | =undefined 17 | > --------------------------------------------------------------------------------