Skip to content

Added basic blink example for Esp32-C6 #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 28, 2024
Merged

Added basic blink example for Esp32-C6 #21

merged 5 commits into from
Jun 28, 2024

Conversation

allexoK
Copy link
Contributor

@allexoK allexoK commented Jun 26, 2024

Hello,

When learning about embedded-Swift, I was surprised that there was no basic blink example (only the LED strip one). So, I decided to create one.

I used the ESP32-C6-Bug board, but it doesn’t really matter as long as there is a normal LED on-board. Alternatively, an external LED can be connected.

allexoK and others added 2 commits June 26, 2024 16:03
Added pictures and added more specific instructions
Copy link
Collaborator

@rauhul rauhul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR there are some hopefully simple changes we need to make before merging this addition :)

Lastly could you also update the README at the repo root to list this example

@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.16)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you increase this to 3.29 and ensure everything still works?

Copy link
Contributor Author

@allexoK allexoK Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, everything works

@@ -0,0 +1,39 @@
# esp32-led-strip-sdk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name is copy-pasted, could you update it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done


This example demonstrates how to integrate with the ESP-IDF SDK via CMake and how to use the standard GPIO library to control LED from Swift. This example is specifically made for the RISC-V MCUs from ESP32 (the Xtensa MCUs are not currently supported by Swift).

![Led on](https://github.com/allexoK/swift-embedded-examples/assets/50021377/c40d4b3a-670b-4743-a8ae-a90c90b905b4)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These links appear to point out of tree, could you fix them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created the pics directory in the project folder and uploaded the pictures there, is it fine?

- If needed, run export.sh to get access to the idf.py script from ESP-IDF.
- Specify the nightly toolchain to be used via the `TOOLCHAINS` environment variable and the target board type by using `idf.py set-target`.
``` console
$ cd esp32-led-strip-sdk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied folder name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


## Running

- Connect the Esp32-C6-Bug board(Or any other board with integrated LED on GPIO pin 8) over a USB cable to your Mac. Alternatively you can just connect external LED to GPIO pin 8 on any other board.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you adjust the formatting here slightly: "...board (or any..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

//
// This source file is part of the Swift open source project
//
// Modified by Karavaev Aleksei
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, fixed

//
// This source file is part of the Swift open source project
//
// Copyright (c) 2023 Apple Inc. and the Swift project authors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make sure to use 2024 as the copyright date on these new additions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in all files of the project

fatalError("cannot reset led")
}

guard gpio_set_direction(ledPin,GPIO_MODE_OUTPUT) == ESP_OK else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a space after the comma

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

//
//===----------------------------------------------------------------------===//

// The code will blink a led attached to GPIO8, to change the led pin change the Led(gpioPin: 8) to something else
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wrap to 80 characters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

## Running

- Connect the Esp32-C6-Bug board(Or any other board with integrated LED on GPIO pin 8) over a USB cable to your Mac. Alternatively you can just connect external LED to GPIO pin 8 on any other board.
- Connect RX pin of USB-UART converter to TX0 pin of your board if you need serial ouput.(You may also need to connect GND converter pin to the GND pin of the board)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here could you add a space after output and remove the parens "...output. You may..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

allexoK added 2 commits June 27, 2024 16:11
…anged copyright date and removed my name, changed copy-pasted names, changed pics location, added example description to root README.
@allexoK
Copy link
Contributor Author

allexoK commented Jun 27, 2024

Hi @rauhul, thanks for the review! :)

I think I fixed everything. I was not sure which table to add the example to (Catalog of Examples or Community Examples). The 'Community Examples' table points to external repositories, so I decided to go with 'Catalog of Examples'.

Let me know if any other changes are required. :)

@allexoK allexoK requested a review from rauhul June 27, 2024 14:38
Copy link
Collaborator

@rauhul rauhul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allexoK one last change and were good to go!


This example demonstrates how to integrate with the ESP-IDF SDK via CMake and how to use the standard GPIO library to control LED from Swift. This example is specifically made for the RISC-V MCUs from ESP32 (the Xtensa MCUs are not currently supported by Swift).

![Led on](pics/ledon.jpg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last nit: could you change this path to assets/images/...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, changed it :)

@rauhul rauhul added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 28, 2024
@rauhul rauhul self-assigned this Jun 28, 2024
Copy link
Collaborator

@rauhul rauhul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastic, thank you for the contribution!

@rauhul rauhul merged commit 52eb879 into apple:main Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants