https://github.com/andrei-markeev/ts2c-target-esp-idf
ESP-IDF target for TS2C transpiler
https://github.com/andrei-markeev/ts2c-target-esp-idf
Last synced: about 1 year ago
JSON representation
ESP-IDF target for TS2C transpiler
- Host: GitHub
- URL: https://github.com/andrei-markeev/ts2c-target-esp-idf
- Owner: andrei-markeev
- Created: 2019-03-23T23:44:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-24T11:20:29.000Z (about 7 years ago)
- Last Synced: 2024-04-24T15:13:34.226Z (about 2 years ago)
- Size: 8.79 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ESP-IDF target for TS2C transpiler
==================================
This projects provides header definitions and tooling for using [TS2C](https://github.com/andrei-markeev/ts2c-target-esp-idf) for ESP-IDF development.
**Status:** Work in progress.
Usage
-----
```
npm install ts2c-target-esp-idf
```
After that, you can create .ts files, `import` all necessary ESP-IDF dependencies and use them:
```ts
import { esp_restart } from 'ts2c-target-esp-idf/esp_system.h';
import { portTICK_PERIOD_MS, vTaskDelay } from 'ts2c-target-esp-idf/freertos/task.h';
import 'ts2c-target-esp-idf/freertos/FreeRTOS.h/index';
console.log("Hello world!");
console.log("Restarting in 10 seconds...");
vTaskDelay(10000 / portTICK_PERIOD_MS);
esp_restart();
```
When your code is ready:
```
npm i -g ts2c
ts2c your-file.ts
```
That will create corresponding .c file, which you can then compile and flash using ESP-IDF tools.
Example above will be transpiled to the following .c file:
```c
#include
#include
#include
#include
int main(void) {
printf("Hello world!\n");
printf("Restarting in 10 seconds...\n");
vTaskDelay(10000 / portTICK_PERIOD_MS);
esp_restart();
return 0;
}
```
More examples - in [examples](https://github.com/andrei-markeev/ts2c-target-esp-idf/tree/master/examples) folder.