An application loader for the M5 Cardputer that runs Javascript.
- M5Cardputer by M5Stack
- JavaScript by Joseph Read
- Flash the firmware.
- Copy the file structure from the SD Card Root folder to the root of your Cardputer's SD Card.
- Anything in boot.js should run automatically.
Description: Sets the script to be executed next when the current script ends.
Parameters:
script
(string): The JavaScript code as a string to be loaded.
Returns: void
Description: Prints the given message to the Serial monitor.
Parameters:
message
(string): The message to print.
Returns: void
Description: Returns the current time in milliseconds since the epoch.
Returns: number
: The current timestamp in milliseconds.
Description: Pauses execution for the specified number of milliseconds.
Parameters:
ms
(number): The number of milliseconds to delay.
Returns: void
Description: Sets the digital value (HIGH or LOW) for a specified pin.
Parameters:
pin
(number): The pin number.value
(boolean): The value to write (true for HIGH, false for LOW).
Returns: void
Description: Configures the specified pin to behave as an input or an output.
Parameters:
pin
(number): The pin number.mode
(number): The mode to set (INPUT, OUTPUT, etc.).
Returns: void
Description: Performs an HTTP GET request to the specified URL. Optionally includes headers.
Parameters:
url
(string): The URL to send the GET request to.headers
(string[]): An array of headers to include in the request. Headers should be provided as key-value pairs in the array. Example:[ "Content-Type", "application/json", "Authorization", "Bearer your_token_here", "Accept", "application/json" ]
Returns: object
: An object with two properties:
response
(number): The HTTP response code.body
(string): The response body.
Description: Creates a color from the given RGB values.
Parameters:
r
(number): The red component (0-255).g
(number): The green component (0-255).b
(number): The blue component (0-255).
Returns: number
: The color value in 16-bit RGB format.
Description: Sets the text color for drawing operations.
Parameters:
color
(number): The color value in 16-bit RGB format.
Returns: void
Description: Sets the text size for drawing operations.
Parameters:
size
(number): The text size multiplier.
Returns: void
Description: Draws a rectangle with the specified parameters.
Parameters:
x
(number): The x-coordinate of the top-left corner.y
(number): The y-coordinate of the top-left corner.width
(number): The width of the rectangle.height
(number): The height of the rectangle.color
(number): The color value in 16-bit RGB format.
Returns: void
Description: Draws a filled rectangle with the specified parameters.
Parameters:
x
(number): The x-coordinate of the top-left corner.y
(number): The y-coordinate of the top-left corner.width
(number): The width of the rectangle.height
(number): The height of the rectangle.color
(number): The color value in 16-bit RGB format.
Returns: void
Description: Draws the specified text at the given coordinates.
Parameters:
text
(string): The text to draw.x
(number): The x-coordinate where the text starts.y
(number): The y-coordinate where the text starts.
Returns: void
Description: Returns the width of the display.
Returns: number
: The width of the display in pixels.
Description: Returns the height of the display.
Returns: number
: The height of the display in pixels.
Description: Returns the current state of the keys pressed on the M5Cardputer.
Returns: string[]
: An array of strings representing the pressed keys. Possible values include "Delete", "Enter", "Alt", "Tab", "Function", "Option", or the actual key character.