-
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.
refs #77 Add a simple LED button template for the M5StampC3U
- Loading branch information
1 parent
058fd80
commit a934762
Showing
12 changed files
with
950 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,39 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
|
||
### PlatformIO ### | ||
.pioenvs | ||
.piolibdeps | ||
.clang_complete | ||
.gcc-flags.json | ||
.pio |
508 changes: 508 additions & 0 deletions
508
reference-designs/M5Stamp-C3U/.vscode/c_cpp_properties.json
Large diffs are not rendered by default.
Oops, something went wrong.
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,10 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"platformio.platformio-ide" | ||
], | ||
"unwantedRecommendations": [ | ||
"ms-vscode.cpptools-extension-pack" | ||
] | ||
} |
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,44 @@ | ||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY | ||
// | ||
// PlatformIO Debugging Solution | ||
// | ||
// Documentation: https://docs.platformio.org/en/latest/plus/debugging.html | ||
// Configuration: https://docs.platformio.org/en/latest/projectconf/sections/env/options/debug/index.html | ||
|
||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "platformio-debug", | ||
"request": "launch", | ||
"name": "PIO Debug", | ||
"executable": "/Users/dkords/dev/repos/M5Stamp-C3U/.pio/build/esp32c3/firmware.elf", | ||
"projectEnvName": "esp32c3", | ||
"toolchainBinDir": "/Users/dkords/.platformio/packages/[email protected]+2021r2-patch5/bin", | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"preLaunchTask": { | ||
"type": "PlatformIO", | ||
"task": "Pre-Debug" | ||
} | ||
}, | ||
{ | ||
"type": "platformio-debug", | ||
"request": "launch", | ||
"name": "PIO Debug (skip Pre-Debug)", | ||
"executable": "/Users/dkords/dev/repos/M5Stamp-C3U/.pio/build/esp32c3/firmware.elf", | ||
"projectEnvName": "esp32c3", | ||
"toolchainBinDir": "/Users/dkords/.platformio/packages/[email protected]+2021r2-patch5/bin", | ||
"internalConsoleOptions": "openOnSessionStart" | ||
}, | ||
{ | ||
"type": "platformio-debug", | ||
"request": "launch", | ||
"name": "PIO Debug (without uploading)", | ||
"executable": "/Users/dkords/dev/repos/M5Stamp-C3U/.pio/build/esp32c3/firmware.elf", | ||
"projectEnvName": "esp32c3", | ||
"toolchainBinDir": "/Users/dkords/.platformio/packages/[email protected]+2021r2-patch5/bin", | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"loadMode": "manual" | ||
} | ||
] | ||
} |
54 changes: 54 additions & 0 deletions
54
reference-designs/M5Stamp-C3U/INO files/ESP32C3-I2Cscan.ino
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,54 @@ | ||
|
||
/********* | ||
Based on Rui Santos | ||
Complete project details at https://randomnerdtutorials.com | ||
*********/ | ||
|
||
#include <Arduino.h> | ||
#include <Wire.h> | ||
|
||
//#define I2C_SDA 1 | ||
//#define I2C_SCL 0 | ||
|
||
|
||
#define I2C_SDA 6 | ||
#define I2C_SCL 7 | ||
|
||
void setup() { | ||
Wire.begin(I2C_SDA, I2C_SCL); | ||
Serial.begin(115200); | ||
Serial.println("\nI2C Scanner"); | ||
} | ||
|
||
void loop() { // start | ||
byte error, address; | ||
int nDevices; | ||
Serial.println("Scanning..."); | ||
nDevices = 0; | ||
for(address = 1; address < 127; address++ ) { | ||
Wire.beginTransmission(address); | ||
error = Wire.endTransmission(); | ||
if (error == 0) { | ||
Serial.print("I2C device found at address 0x"); | ||
if (address<16) { | ||
Serial.print("0"); | ||
} | ||
Serial.println(address,HEX); | ||
nDevices++; | ||
} | ||
else if (error==4) { | ||
Serial.print("Unknow error at address 0x"); | ||
if (address<16) { | ||
Serial.print("0"); | ||
} | ||
Serial.println(address,HEX); | ||
} | ||
} | ||
if (nDevices == 0) { | ||
Serial.println("No I2C devices found\n"); | ||
} | ||
else { | ||
Serial.println("done\n"); | ||
} | ||
delay(5000); | ||
} // end |
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 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <https://unlicense.org> |
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,63 @@ | ||
# Overview | ||
|
||
This is a template for an M5StackC3U / PlatformIO. | ||
|
||
Because this is slightly exotic as a platform, verify that this works as a basis for a platform. | ||
|
||
Original fork was forked from a free rtos oriented project using IDF. | ||
|
||
https://github.com/leCandas/M5Stamp-C3 | ||
|
||
|
||
## This is an example project for M5Stamp C3U on PlatformIO | ||
|
||
Project forked to explore how to use this board. | ||
### Work in progress: | ||
- [x] Setup things with Arduino IDE 1.8.19, boards and lib. | ||
Here on Master branch. | ||
- [x] Understand how to communicate with I2C, | ||
Check branch [I2Cscan](https://github.com/nicolasdb/M5Stamp-C3U/tree/I2Cscan) | ||
- [x] Play with a Oled .096 display and the ~~ENV unit~~ DHT11, | ||
Check branch [OledDHT11](https://github.com/nicolasdb/M5Stamp-C3U/tree/OledDHT11) | ||
- [x] Expand GPIO with MCP23017 and I2C. | ||
Check branch [mcp23017](https://github.com/nicolasdb/M5Stamp-C3U/tree/mcp23017) | ||
- [x] Then go back to setup the board in platform.io, | ||
Here on Master branch. | ||
- [ ] connect and log data with the "data logger shield for WIFI D1 MINI" | ||
- [ ] measuring of State of a battery (V) and power form solar pannel (A) | ||
- [ ] return the tilt values from ADXL345 on a graph with web server. | ||
|
||
---- | ||
|
||
### Notes: | ||
Pay attention to the model you have. | ||
- C3 need a FTDI driver | ||
- C3U doesn't but need to be in program download mode. | ||
|
||
For more stuff, check the [issue #1](https://github.com/nicolasdb/M5Stamp-C3U/issues/1) | ||
|
||
#### - To use with Arduino IDE | ||
[https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-arduino-ide](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-arduino-ide) | ||
|
||
#### - To use with Platform.io | ||
|
||
Clone this repo, everything is adjusted in `platformio.ini` | ||
Just build and upload | ||
|
||
#### - Test program | ||
`main.cpp` : Internal led will change its color with each press on the button. | ||
|
||
> For ARDUINO IDE: You can copy/paste the code from `main.cpp` Don't forget to install libraries. | ||
#### - To enter into "program download" mode operation: | ||
|
||
- Long press the center button (G9) of STAMP C3U under power failure condition. | ||
- Connect USB to the computer while holding the button, | ||
|
||
after that, the port is successfully identified, program burning. | ||
|
||
> Windows 10, Arduino IDE | ||
![image](https://user-images.githubusercontent.com/12049360/185742555-b4190a52-7720-4787-beb9-55e36e271cf4.png) | ||
|
||
> Manjaro kernel 5.15 LTS, Arduino IDE | ||
![image](https://user-images.githubusercontent.com/12049360/189372496-20315b99-53ec-4071-b5c7-1e33a9ff0d8e.png) |
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,39 @@ | ||
|
||
This directory is intended for project header files. | ||
|
||
A header file is a file containing C declarations and macro definitions | ||
to be shared between several project source files. You request the use of a | ||
header file in your project source file (C, C++, etc) located in `src` folder | ||
by including it, with the C preprocessing directive `#include'. | ||
|
||
```src/main.c | ||
|
||
#include "header.h" | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
``` | ||
|
||
Including a header file produces the same results as copying the header file | ||
into each source file that needs it. Such copying would be time-consuming | ||
and error-prone. With a header file, the related declarations appear | ||
in only one place. If they need to be changed, they can be changed in one | ||
place, and programs that include the header file will automatically use the | ||
new version when next recompiled. The header file eliminates the labor of | ||
finding and changing all the copies as well as the risk that a failure to | ||
find one copy will result in inconsistencies within a program. | ||
|
||
In C, the usual convention is to give header files names that end with `.h'. | ||
It is most portable to use only letters, digits, dashes, and underscores in | ||
header file names, and at most one dot. | ||
|
||
Read more about using header files in official GCC documentation: | ||
|
||
* Include Syntax | ||
* Include Operation | ||
* Once-Only Headers | ||
* Computed Includes | ||
|
||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html |
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,46 @@ | ||
|
||
This directory is intended for project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link into executable file. | ||
|
||
The source code of each library should be placed in a an own separate directory | ||
("lib/your_library_name/[here are source files]"). | ||
|
||
For example, see a structure of the following two libraries `Foo` and `Bar`: | ||
|
||
|--lib | ||
| | | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html | ||
| | | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| | | ||
| |- README --> THIS FILE | ||
| | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
and a contents of `src/main.c`: | ||
``` | ||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
|
||
``` | ||
|
||
PlatformIO Library Dependency Finder will find automatically dependent | ||
libraries scanning project source files. | ||
|
||
More information about PlatformIO Library Dependency Finder | ||
- https://docs.platformio.org/page/librarymanager/ldf.html |
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 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[env:esp32c3] | ||
platform = espressif32 | ||
# platform = | ||
# https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master | ||
# platform_packages = | ||
# framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3 | ||
# platformio/tool-esptoolpy @ https://github.com/tasmota/esptool/releases/download/v3.2/esptool-v3.2.zip | ||
framework = arduino | ||
board = esp32-c3-devkitm-1 | ||
board_build.mcu = esp32c3 | ||
board_build.partitions = huge_app.csv | ||
board_build.variant = esp32c3 | ||
board_build.f_cpu = 160000000L | ||
board_build.f_flash = 80000000L | ||
board_build.flash_mode = dio | ||
board_build.arduino.ldscript = esp32c3_out.ld | ||
build_unflags = | ||
-DARDUINO_ESP32_DEV | ||
; -DARDUINO_VARIANT="esp32" | ||
build_flags = | ||
-DARDUINO_ESP32C3_DEV | ||
; -DARDUINO_VARIANT="esp32c3" | ||
lib_deps = | ||
adafruit/Adafruit NeoPixel@^1.10.4 | ||
monitor_speed = 115200 | ||
monitor_filters = time | ||
|
||
|
||
|
||
|
||
; Work also with: | ||
; [env:ESP32-C3] | ||
; platform = espressif32 | ||
; platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3 | ||
; board = esp32-c3-devkitm-1 | ||
; framework = arduino | ||
; lib_deps = adafruit/Adafruit NeoPixel@^1.10.4 | ||
; ;upload_port = COM8 | ||
; board_build.flash_mode = dio |
Oops, something went wrong.