-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e10b66d
commit b03add9
Showing
27 changed files
with
1,588 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
declare module "adc" { | ||
type Atten = number; | ||
|
||
const Attenuation: { | ||
readonly Db0: Atten; | ||
readonly Db2_5: Atten; | ||
readonly Db6: Atten; | ||
readonly Db11: Atten; | ||
}; | ||
|
||
|
||
/** | ||
* Enable ADC on the given pin. | ||
* @param pin The pin to enable ADC on. | ||
*/ | ||
function configure(pin: number, attenuation?: Atten): void; | ||
|
||
/** | ||
* Read the value of the given pin. | ||
* @param pin The pin to read. | ||
* @returns The value of the pin (0-1023) | ||
*/ | ||
function read(pin: number): number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
declare interface Writable { | ||
/** | ||
* Write the given data to the stream. | ||
* @param data The data to write. | ||
*/ | ||
write(data: string): void; | ||
} | ||
|
||
declare interface Readable { | ||
/** | ||
* Read a single character from the stream. | ||
* @returns Promise that resolves to the character read. | ||
*/ | ||
get(): Promise<string>; | ||
|
||
/** | ||
* Read a chunk of data from the stream. The size of the chunk is | ||
* given by the implementation and available data. | ||
* @returns Promise that resolves to the data read. | ||
*/ | ||
read(): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
declare module "fs" { | ||
interface File { | ||
path: string; | ||
|
||
/** | ||
* Check if the file is open. | ||
*/ | ||
isOpen(): boolean; | ||
|
||
/** | ||
* Close the file. | ||
*/ | ||
close(): void; | ||
|
||
/** | ||
* Read characters from the file. | ||
* @param len The number of characters to read. | ||
*/ | ||
read(len: number): string; | ||
|
||
/** | ||
* Write text to the file. | ||
* @param text The text to write. | ||
*/ | ||
write(text: string): void; | ||
} | ||
|
||
/** | ||
* Open the given file in the given mode. | ||
* @param path The path to the file. | ||
* @param mode The mode to open the file in ("r", "w", "a" and combinations). | ||
*/ | ||
function open(path: string, mode: string): File; | ||
|
||
/** | ||
* Check if the given path exists. | ||
* @param path The path to check. | ||
* @returns True if the path exists, false otherwise. | ||
*/ | ||
function exists(path: string): boolean; | ||
|
||
/** | ||
* Check if the given path is a file. | ||
* @param path The path to check. | ||
* @returns True if the path is a file, false otherwise. | ||
*/ | ||
function isFile(path: string): boolean; | ||
|
||
/** | ||
* Check if the given path is a directory. | ||
* @param path The path to check. | ||
* @returns True if the path is a directory, false otherwise. | ||
*/ | ||
function isDirectory(path: string): boolean; | ||
|
||
/** | ||
* Create a directory at the given path. | ||
* @param path The path to create the directory at. | ||
*/ | ||
function mkdir(path: string): void; | ||
|
||
/** | ||
* Remove the file at the given path. | ||
* @param path The path to the file to remove. | ||
*/ | ||
function rm(path: string): void; | ||
|
||
/** | ||
* Remove the directory at the given path. | ||
* @param path The path to the directory to remove. | ||
*/ | ||
function rmdir(path: string): void; | ||
|
||
/** | ||
* List the files in the given directory. | ||
* @param path The path to the directory to list. | ||
* @returns An array of file names in the directory. | ||
*/ | ||
function readdir(path: string): string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
declare module "gpio" { | ||
const PinMode: { | ||
readonly DISABLE: number, | ||
readonly OUTPUT: number, | ||
readonly INPUT: number, | ||
readonly INPUT_PULLUP: number, | ||
readonly INPUT_PULLDOWN: number, | ||
}; | ||
|
||
interface EventInfo { | ||
timestamp: Timestamp; | ||
} | ||
|
||
/** | ||
* Configure the given pin. | ||
* @param pin The pin to configure. | ||
* @param mode The mode to configure the pin in. | ||
*/ | ||
function pinMode(pin: number, mode: number): void; | ||
|
||
/** | ||
* Write digital value to the given pin. | ||
* @param pin The pin to write to. | ||
* @param value The value to write. | ||
*/ | ||
function write(pin: number, value: number): void; | ||
|
||
/** | ||
* Read digital value from the given pin. | ||
* @param pin The pin to read from. | ||
* @returns The value of the pin (0 or 1). | ||
*/ | ||
function read(pin: number): number; | ||
|
||
/** | ||
* Set event handler for the given pin. | ||
* @param event The event to handle. | ||
* @param pin The pin to handle the event for. | ||
* @param callback The callback to call when the event occurs. | ||
*/ | ||
function on(event: "rising" | "falling" | "change", pin: number, callback: (info: EventInfo) => void): void; | ||
|
||
/** | ||
* Remove event handler for the given pin. | ||
* @param event The event to remove. | ||
* @param pin The pin to remove the event handler for. | ||
*/ | ||
function off(event: "rising" | "falling" | "change", pin: number): void; | ||
} |
Oops, something went wrong.