CPU - Central Processing Unit
This peripheral contains most of miscellaneous functions that LIKO-12 would use.
- Version: v1.0.0
- Available since: LIKO-12 v0.6.0
- Last updated in: LIKO-12 v0.8.0
Methods:
CPU.clearClipboard
Clears the clipboard content.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
CPU.clearClipboard()
CPU.clearEStack
Clears the events stack.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
CPU.clearEStack()
CPU.clipboard
Read or write to/from the clipboard.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
Usages:
1. Read the clipboard content:
content = CPU.clipboard()
Returns:
- content (string): The clipboard content.
2. Set the clipboard content:
CPU.clipboard(content)
Arguments:
- <content> (string, number): The new clipboard content.
CPU.cprint
Print into the developer terminal, that can be shown by running LIKO-12 from terminal.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
CPU.cprint(text, ...)
Arguments:
- <text> (any): The text to print.
- [...] (any) (Default:
nil
): Will be automatically concated with the first argument, works the same way of the standard Lua print.
CPU.getFPS
Returns the current frame per second count.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
fps = CPU.getFPS()
Returns:
- fps (number): The FPS.
CPU.getHostOS
Returns the operating system that's LIKO-12 is running on.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
os = CPU.getHostOS()
Returns:
- os (string): The current operating system. "OS X", "Windows", "Linux", "Android" or "iOS".
CPU.getSaveDirectory
Returns LIKO-12 save directory (the appdata directory) in the HOST filesystem.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
dir = CPU.getSaveDirectory()
Returns:
- dir (string): LIKO-12 save directory (the appdata directory) in the HOST filesystem.
CPU.isMobile
Returns true if LIKO-12 is running on a mobile device (Android or iOS).
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
mobile = CPU.isMobile()
Returns:
- mobile (boolean): Is LIKO-12 running on a mobile device ?
CPU.openAppdata
Opens a specific directory inside the LIKO-12 appdata folder using the HOST file explorer.
Opens a specific directory inside the LIKO-12 appdata folder using the HOST file explorer.
In order to show a folder inside the virtual drives open /drives/[driveName]/...
.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
CPU.openAppdata(dir)
Arguments:
- <dir> (string): The directory to open in the HOST file explorer.
CPU.pullEvent
Pulls an event from the events stack.
This function is used internally by DiskOS to run the default event loop, which calls the callback functions that start by _
like _update
and _mousepressed
, etc..
Events in LIKO-12 may be pulled directly, or pulled from a stack if there are already, the stack may fill up when CPU sleep()
or GPU flip()
are called.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
event, a, b, c, d, e, f = CPU.pullEvent()
Returns:
- event (string): The event name, can be any of the callbacks names without the "_" at the start.
- a (any): First argument.
- b (any): Second argument.
- c (any): Third argument.
- d (any): Forth argument.
- e (any): Fifth argument.
- f (any): Sixth argument.
CPU.rawPullEvent
Pulls a new event directly, returns it and stores it in the events stack, used by DiskOS to handle the escape
key.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
event, a, b, c, d, e, f = CPU.rawPullEvent()
Returns:
- event (string): The event name, can be any of the callbacks names without the "_" at the start.
- a (any): First argument.
- b (any): Second argument.
- c (any): Third argument.
- d (any): Forth argument.
- e (any): Fifth argument.
- f (any): Sixth argument.
CPU.reboot
Reboot LIKO-12.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
Usages:
1. Soft Reboot:
Soft reboots LIKO-12 by doing an internal trick to reload the BIOS and bootup again, will leave some garbage that will be cleaned automatically by the Lua garbage collector.
CPU.reboot()
2. Hard Reboot:
Hard reboots LIKO-12 by reinitializing the LÖVE engine, will clear the whole Lua state, and re-create the window.
CPU.reboot(true)
Arguments:
true
(boolean)
CPU.shutdown
Shutdown/exit LIKO-12.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
CPU.shutdown()
CPU.sleep
Sleeps (pauses) the current execution for specific amount of seconds.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
CPU.sleep(time)
Arguments:
- <time> (number): The amount of seconds to sleep.
CPU.triggerEvent
Add a new event to the events stack.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
CPU.triggerEvent(event, a, b, c, d, e, f)
Arguments:
- <event> (string): The event name.
- [a] (any) (Default:
nil
): First argument. - [b] (any) (Default:
nil
): Second argument. - [c] (any) (Default:
nil
): Third argument. - [d] (any) (Default:
nil
): Forth argument. - [e] (any) (Default:
nil
): Fifth argument. - [f] (any) (Default:
nil
): Sixth argument.
Events:
Please note that the example functions won't be called automatically, there must be some kind of an events handler for CPU.pullEvent, check if the LIKO-12 OS you're using has one.
update
Triggered almost every frame, with the delta-time between each called passed in.
- Available since: CPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: CPU: v1.0.0, LIKO-12: v0.6.0
update
is triggered 60 times a second for most of the devices, but that depends on the screen refresh rate, so it can be more or less!
update
can be triggered for over than 2000 times a second if the vsync of the GPU was disabled due to user's configuration!
function _update(dt)
--Content run when the event is triggered
end
Arguments:
- dt (number): The time passed since the previous
update
triggered, measured in seconds.