From fac1ebcd3f1d1d570735fa6b2d57641b20c4ad8d Mon Sep 17 00:00:00 2001 From: caelwarner Date: Sat, 11 Mar 2023 16:12:58 -0800 Subject: [PATCH] Added documentation for most peripherals - Lua documentation has been added for all peripherals except the train station (not looking forward to writing that one) - This documentation will be added to the GitHub wiki pages --- wiki/Lua-Display-Link.md | 88 +++++++++++++++++++++++++++ wiki/Lua-Rotation-Speed-Controller.md | 18 ++++++ wiki/Lua-Sequenced-Gearshift.md | 29 +++++++++ wiki/Lua-Speedometer.md | 10 +++ wiki/Lua-Stressometer.md | 18 ++++++ wiki/README.md | 2 + 6 files changed, 165 insertions(+) create mode 100644 wiki/Lua-Display-Link.md create mode 100644 wiki/Lua-Rotation-Speed-Controller.md create mode 100644 wiki/Lua-Sequenced-Gearshift.md create mode 100644 wiki/Lua-Speedometer.md create mode 100644 wiki/Lua-Stressometer.md create mode 100644 wiki/README.md diff --git a/wiki/Lua-Display-Link.md b/wiki/Lua-Display-Link.md new file mode 100644 index 000000000..727ac8139 --- /dev/null +++ b/wiki/Lua-Display-Link.md @@ -0,0 +1,88 @@ +| Method | Description | +|---------------------------------------|------------------------------------------------------| +| [`setCursorPos(x, y)`](#setCursorPos) | Sets the cursor position | +| [`getCursorPos()`](#getCursorPos) | Gets the current cursor position | +| [`getSize()`](#getSize) | Gets the display size of the connected target | +| [`isColor()`](#isColor) | Whether the connected display target colors | +| [`isColour()`](#isColour) | Whether the connected display target supports colours | +| [`write(text)`](#writetext) | Writes text at the current cursor position | +| [`clearLine()`](#clearLine) | Clears the line at the current cursor position | +| [`clear()`](#clear) | Clears the whole display | +| [`update()`](#update) | Pushes an update to the display target | + +--- +### `setCursorPos(x, y)` +Sets the cursor position. Can be outside the bounds of the connected display. + +**Parameters** +- _x:_ `number` The cursor x position +- _y:_ `number` The cursor y position + +--- +### `getCursorPos()` +Gets the current cursor position. + +**Returns** +- `number` The cursor x position +- `number` The cursor y position + +--- +### `getSize()` +Gets the size of the connected display target + +**Returns** +- `number` The width of the display +- `number` The height of the display + +--- +### `isColor()` +Checks whether the connected display target supports color + +**Returns** +- `boolean` Whether the display support color + +--- +### `isColour()` +Checks whether the connected display target supports colour + +**Returns** +- `boolean` Whether the display support colour + +--- +### `write(text)` +Writes text at the current cursor position, moving the cursor to the end of the text. +This only writes to an internal buffer. For the changes to show up on the display [`update()`](#update) must be used. +If the cursor is outside the bounds of the connected display the text will not show up on the display. + +This will overwrite any text currently at cursor position. + +**Parameters** +- _text:_ `string` Text to write. + +**See also** +- [`update()`](#update) To push the changes to the display target. + +--- +### `clearLine()` +Clears the line at the current cursor position. + +**See also** +- [`update()`](#update) To push the changes to the display target. + +--- +### `clear()` +Clears the whole display. + +**See also** +- [`update()`](#update) To push the changes to the display target. + +--- +### `update()` +Pushes any changes to the connected display target. +Any changes made are only made to an internal buffer. +For them to show up on the display they must be pushed to the display using this function. +This allows for this peripheral to be better multithreaded and for users to be able to change multiple lines at once by +using multiple [`write(text)`](#writetext) calls and then one [`update()`](#update) call. + +**See also** +- [`write(text)`](#writetext) To write text to the display target. diff --git a/wiki/Lua-Rotation-Speed-Controller.md b/wiki/Lua-Rotation-Speed-Controller.md new file mode 100644 index 000000000..ee48b17d1 --- /dev/null +++ b/wiki/Lua-Rotation-Speed-Controller.md @@ -0,0 +1,18 @@ +| Method | Description | +|:-----------------------------------------------:|----------------------------------------| +| [`setTargetSpeed(speed)`](#setTargetSpeedspeed) | Sets the target rotation speed | +| [`getTargetSpeed()`](#getTargetSpeed) | Gets the current target rotation speed | + +--- +### `setTargetSpeed(speed)` +Sets the rotation speed controller's target speed. + +**Parameters** +- _speed:_ `number` Target speed. Must be an integer within range of [-256..256]. Values outside of this range will be clamped. + +--- +### `getTargetSpeed()` +Gets the rotation speed controller's current target speed. + +**Returns** +- `number` Current target rotation speed. diff --git a/wiki/Lua-Sequenced-Gearshift.md b/wiki/Lua-Sequenced-Gearshift.md new file mode 100644 index 000000000..99713aa6d --- /dev/null +++ b/wiki/Lua-Sequenced-Gearshift.md @@ -0,0 +1,29 @@ +| Method | Description | +|------------------------------------------------------|--------------------------------------------------------------| +| [`rotate(angle, [modifier])`](#rotateangle-modifier) | Rotates shaft by a set angle | +| [`move(distance, [modifier])`](#moveangle-modifier) | Rotates shaft to move Piston/Pulley/Gantry by a set distance | +| [`isRunning()`](#isRunning) | Checks if the gearshift is spinning | + +--- +### `rotate(angle, [modifier])` + +Rotates connected components by a set angle. + +**Parameters** +- _angle:_ `number` Angle to rotate shaft by. Must be a positive integer. +- _modifier?:_ `number = 1` Speed modifier which can be used to reverse rotation. Must be an integer within range of [-2..2]. Values out of this range will cause the modifier to revert to its default of 1. + +--- +### `move(distance, [modifier])` +Rotates connected components to move connected piston, pulley or gantry contractions by a set distance. + +**Parameters** +- _distance:_ `number` Distance to move connected piston, pulley or gantry contraptions by. Must be a positive integer. +- _modifier?:_ `number = 1` Speed modifier which can be used to reverse rotation. Must be an integer within range of [-2..2]. Values out of this range will cause the modifier to revert to its default of 1. + +--- +### `isRunning()` +Checks if the sequenced gearshift is currently spinning. + +**Returns** +- `boolean` Whether the sequenced gearshift is currently spinning. diff --git a/wiki/Lua-Speedometer.md b/wiki/Lua-Speedometer.md new file mode 100644 index 000000000..e1536cbe0 --- /dev/null +++ b/wiki/Lua-Speedometer.md @@ -0,0 +1,10 @@ +| Method | Description | +|---------------------------|---------------------------------| +| [`getSpeed()`](#getSpeed) | Gets the current rotation speed | + +--- +### `getSpeed()` +Gets the current rotation speed of the attached components + +**Returns** +- `number` The current rotation speed diff --git a/wiki/Lua-Stressometer.md b/wiki/Lua-Stressometer.md new file mode 100644 index 000000000..bf4e5df72 --- /dev/null +++ b/wiki/Lua-Stressometer.md @@ -0,0 +1,18 @@ +| Method | Description | +|---------------------------------------------|--------------------------------| +| [`getStress()`](#getStress) | Gets the current stress level | +| [`getStressCapacity()`](#getStressCapacity) | Gets the total stress capacity | + +--- +### `getStress()` +Gets the connected network's current stress level + +**Returns** +- `number` The current stress level + +--- +### `getStressCapacity()` +Gets the connected network's total stress capacity + +**Returns** +- `number` The total stress capacity diff --git a/wiki/README.md b/wiki/README.md new file mode 100644 index 000000000..cf91b97ae --- /dev/null +++ b/wiki/README.md @@ -0,0 +1,2 @@ +Just before this PR is about to be merged this /wiki folder will be removed from the PR and the pages will be added to +the wiki section of the Create GitHub under API Reference