documentation tweaks

This commit is contained in:
Gordon Williams 2024-10-25 14:20:02 +01:00
parent 70bb362bed
commit 50249264b6
7 changed files with 23 additions and 21 deletions

View File

@ -1341,7 +1341,7 @@ JsVar *jswrap_graphics_setPixel(JsVar *parent, int x, int y, JsVar *color) {
"ifndef" : "SAVE_ON_FLASH",
"generate" : "jswrap_graphics_toColor",
"params" : [
["r","JsVar","Red (between 0 and 1) **OR** an integer representing the color in the current bit depth and color order **OR** a hexidecimal color string of the form `'#rrggbb' or `'#rgb'`"],
["r","JsVar","Red (between 0 and 1) **OR** an integer representing the color in the current bit depth and color order **OR** a hexidecimal color string of the form `'#rrggbb'` or `'#rgb'`"],
["g","JsVar","Green (between 0 and 1)"],
["b","JsVar","Blue (between 0 and 1)"]
],

View File

@ -410,8 +410,7 @@ require("http").get("http://pur3.co.uk/hello.txt", function(res) {
});
```
See `http.request()` and [the Internet page](/Internet) and ` for more usage
examples.
See `http.request()` and [the Internet page](/Internet) for more usage examples.
*/
JsVar *jswrap_http_get(JsVar *options, JsVar *callback) {
JsNetwork net;

View File

@ -538,7 +538,7 @@ void jswrap_dgram_socket_send(JsVar *parent, JsVar *buffer, JsVar *offset, JsVar
]
}
The 'message' event is called when a datagram message is received. If a handler
is defined with `X.on('message', function(msg) { ... })` then it will be called`
is defined with `X.on('message', function(msg) { ... })` then it will be called
*/
/*JSON{
@ -662,7 +662,7 @@ You can also:
* Just specify the filename (<=100 characters) and it will be loaded and parsed
if you have an SD card connected. For instance `options.key = "key.pem";`
* Specify a function, which will be called to retrieve the data. For instance
`options.key = function() { eeprom.load_my_info(); };
`options.key = function() { eeprom.load_my_info(); };`
For more information about generating and using certificates, see:

View File

@ -303,7 +303,7 @@ for className in sorted(classes, key=lambda s: s.lower()):
html(" </ul>")
html(' </div><!-- Contents -->')
html(" <a class=\"blush\" name=\"top\"\>");
html(" <a class=\"blush\" name=\"top\">");
#html(" <h2>Detail</h2>")
lastClass = "XXX"
for jsondata in detail:
@ -393,16 +393,16 @@ for jsondata in detail:
if "#if" in jsondata:
d = jsondata["#if"];
dprefix = "This is only available in ";
if re.match('^!defined\((.+?)\) && !defined\((.+?)\)$', d):
if re.match(r'^!defined\((.+?)\) && !defined\((.+?)\)$', d):
dprefix = "This is not available in ";
d = re.sub('^!defined\((.+?)\) && !defined\((.+?)\)$', "defined(\\1) or defined(\\2)", d)
if re.match('^!defined\((.+?)\)$', d):
d = re.sub(r'^!defined\((.+?)\) && !defined\((.+?)\)$', r"defined(\\1) or defined(\\2)", d)
if re.match(r'^!defined\((.+?)\)$', d):
dprefix = "This is not available in ";
d = re.sub('^!defined\((.+?)\)$', "defined(\\1)", d)
d = re.sub('!defined\(', "not defined(", d)
d = re.sub(r'^!defined\((.+?)\)$', r"defined(\\1)", d)
d = re.sub(r'!defined\(', r"not defined(", d)
d = d.replace("||", " and ").replace("&&", " with ")
d = re.sub('defined\((.+?)\)', replace_with_ifdef_description, d)
d = re.sub('(.*)_COUNT>=(.*)', "devices with more than \\2 \\1 peripherals", d)
d = re.sub(r'defined\((.+?)\)', replace_with_ifdef_description, d)
d = re.sub(r'(.*)_COUNT>=(.*)', r"devices with more than \\2 \\1 peripherals", d)
desc.append("\n\n**Note:** "+dprefix+d);
html_description(desc, jsondata["name"])

View File

@ -814,17 +814,13 @@ For instance:
E.pipe("This is a really big String",
{write: print},
{chunkSize:1, complete:()=>print("Finished!")});
// Pipe the numbers 1 to 100 to a StorageFile in Storage
E.pipe({ n:0, read : function() { if (this.n<100) return (this.n++)+"\n"; }},
require("Storage").open("testfile","w"));
// Pipe a StorageFile straight to the Bluetooth UART
E.pipe(require("Storage").open("testfile","r"), Bluetooth);
// Pipe a normal file in Storage (not StorageFile) straight to the Bluetooth UART
E.pipe(require("Storage").read("blob.txt"), Bluetooth);
// Pipe a normal file in Storage as a response to an HTTP request
function onPageRequest(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
@ -930,12 +926,18 @@ flat string of the same length, the backing string will be returned without
doing a copy or other allocation. The same applies if there's a single argument
which is itself a flat string.
```JS
```
E.toString(0,1,2,"Hi",3)
"\0\1\2Hi\3"
```
```
E.toString(1,2,{data:[3,4], count:4},5,6)
"\1\2\3\4\3\4\3\4\3\4\5\6"
>E.toString(1,2,{callback : () => "Hello World"},5,6)
```
```
E.toString(1,2,{callback : () => "Hello World"},5,6)
="\1\2Hello World\5\6"
```
@ -944,7 +946,6 @@ or would return `undefined` if one couldn't be allocated. Now, it will return
a normal (fragmented) String if a contiguous chunk of memory cannot be allocated.
You can still check if the returned value is a Flat string using `E.getAddressOf(str, true)!=0`,
or can use `E.toFlatString` instead.
*/
JsVar *jswrap_espruino_toString(JsVar *args) {
return jswrap_espruino_toStringX(args, false);

View File

@ -443,7 +443,7 @@ Print a string to the serial port - without a line feed
Print a line to the serial port with a newline (`\r\n`) at the end of it.
**Note:** This function converts data to a string first, e.g.
`Serial.print([1,2,3])` is equivalent to `Serial.print("1,2,3"). If you'd like
`Serial.print([1,2,3])` is equivalent to `Serial.print("1,2,3")`. If you'd like
to write raw bytes, use `Serial.write`.
*/
void jswrap_serial_print(JsVar *parent, JsVar *str) {

View File

@ -188,7 +188,9 @@ for (var i=0;i<1000;i++) w.buffer[i]=128+120*Math.sin(i/2);
analogWrite(H0, 0.5, {freq:80000}); // set up H0 to output an analog value by PWM
w.on("finish", () => print("Done!"))
w.startOutput(H0,8000); // start playback
```
```JS
// On 2v25, from Storage
var f = require("Storage").read("sound.pcm");
var w = new Waveform(E.toArrayBuffer(f));