Skip to content
Snippets Groups Projects
Commit fb155bad authored by Jan Grewe's avatar Jan Grewe
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
/src/config.h
{
// 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 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 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
; 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:esp32dev]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
upload_port = COM8
monitor_port = COM8
monitor_speed = 115200
lib_deps =
https://github.com/ayushsharma82/ESPConnect.git
https://github.com/me-no-dev/AsyncTCP.git
https://github.com/me-no-dev/ESPAsyncWebServer.git
https://github.com/ayushsharma82/AsyncElegantOTA.git
https://github.com/PlummersSoftwareLLC/SmartMatrix.git
https://github.com/adafruit/Adafruit-GFX-Library.git
https://github.com/marcmerlin/Framebuffer_GFX.git
https://github.com/FastLED/FastLED.git
https://github.com/marcmerlin/SmartMatrix_GFX.git
[env:esp32dev_ota]
extends = env:esp32dev
#upload_port = matrixoflife.local
#upload_protocol = espota
upload_protocol = custom
upload_url = http://matrixoflife.local/update
extra_scripts = platformio_upload.py
# Allows PlatformIO to upload directly to AsyncElegantOTA
#
# To use:
# - copy this script into the same folder as your platformio.ini
# - set the following for your project in platformio.ini:
#
# extra_scripts = platformio_upload.py
# upload_protocol = custom
# upload_url = <your upload URL>
#
# An example of an upload URL:
# upload_URL = http://192.168.1.123/update
import requests
import hashlib
Import('env')
try:
from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
from tqdm import tqdm
except ImportError:
env.Execute("$PYTHONEXE -m pip install requests_toolbelt")
env.Execute("$PYTHONEXE -m pip install tqdm")
from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
from tqdm import tqdm
def on_upload(source, target, env):
firmware_path = str(source[0])
upload_url = env.GetProjectOption('upload_url')
with open(firmware_path, 'rb') as firmware:
md5 = hashlib.md5(firmware.read()).hexdigest()
firmware.seek(0)
encoder = MultipartEncoder(fields={
'MD5': md5,
'firmware': ('firmware', firmware, 'application/octet-stream')}
)
bar = tqdm(desc='Upload Progress',
total=encoder.len,
dynamic_ncols=True,
unit='B',
unit_scale=True,
unit_divisor=1024
)
monitor = MultipartEncoderMonitor(encoder, lambda monitor: bar.update(monitor.bytes_read - bar.n))
response = requests.post(upload_url, data=monitor, headers={'Content-Type': monitor.content_type})
bar.close()
print(response,response.text)
env.Replace(UPLOADCMD=on_upload)
#define WIFI_SSID "YourSSID"
#define WIFI_PSK "YourPSK"
#define HOSTNAME "MatrixOfLife"
\ No newline at end of file
#include <Arduino.h>
#include "display.h"
#define COLOR_DEPTH 24 // known working: 24, 48 - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24
const uint8_t kMatrixWidth = 64; // known working: 32, 64, 96, 128
const uint8_t kMatrixHeight = 64; // known working: 16, 32, 48, 64
const uint8_t kRefreshDepth = 24; // known working: 24, 36, 48
const uint8_t kDmaBufferRows = 2; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
const uint8_t kPanelType = SMARTMATRIX_HUB75_64ROW_MOD32SCAN; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels
const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE); // see http://docs.pixelmatix.com/SmartMatrix for options
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);
const uint8_t kIndexedLayerOptions = (SM_INDEXED_OPTIONS_NONE);
const int defaultBrightness = (25*255)/100; // (10%) brightness
const int defaultScrollOffset = 6;
const rgb24 defaultBackgroundColor = {0x40, 0, 0};
SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
SMARTMATRIX_ALLOCATE_INDEXED_LAYER(indexedLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kIndexedLayerOptions);
void setupDisplay() {
matrix.addLayer(&backgroundLayer);
matrix.addLayer(&scrollingLayer);
matrix.addLayer(&indexedLayer);
matrix.begin();
matrix.setBrightness(defaultBrightness);
scrollingLayer.setOffsetFromTop(defaultScrollOffset);
backgroundLayer.enableColorCorrection(true);
}
void displayLoop() {
scrollingLayer.setColor({0xff, 0xff, 0xff});
scrollingLayer.setMode(wrapForward);
scrollingLayer.setSpeed(40);
scrollingLayer.setFont(font6x10);
scrollingLayer.start("SmartMatrix Demo", 1);
delay(5000);
}
#ifndef DISPLAY_H
#define DISPLAY_H
#include <Arduino.h>
#include <MatrixHardware_ESP32_V0.h>
#include <SmartMatrix.h>
void setupDisplay();
void displayLoop();
#endif
#include <Arduino.h>
#include "utils.h"
#include "network.h"
#include "display.h"
void setup() {
Serial.begin(115200);
logLine("", true);
setupNetwork();
setupDisplay();
}
void loop() {
displayLoop();
}
#include <Arduino.h>
#include "config.h"
#include "utils.h"
#include "network.h"
AsyncWebServer server(80);
MDNSResponder mdns;
void setupNetwork() {
setupWifi();
setupMDNS();
setupWebserver();
}
void setupWifi() {
ESPConnect.autoConnect(HOSTNAME);
if(ESPConnect.begin(&server)){
logLine("Connected to WiFi: ", false);
logLine(WiFi.localIP().toString());
}else{
logLine("Failed to connect to WiFi");
}
}
void setupMDNS() {
if (mdns.begin(HOSTNAME)) {
logLine("MDNS responder started");
mdns.addService("http", "tcp", 80);
mdns.addService("ws", "tcp", 81);
} else {
logLine("MDNS.begin failed");
}
}
void setupWebserver() {
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/plain", "Hi! I am ESP32.");
});
AsyncElegantOTA.begin(&server);
server.begin();
Serial.println("HTTP server started");
}
#ifndef NETWORK_H
#define NETWORK_H
#include <Arduino.h>
#include <ESPConnect.h>
#include <Wifi.h>
#include <ESPmDNS.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <AsyncElegantOTA.h>
void setupNetwork();
void setupMDNS();
void setupWifi();
void setupWebserver();
#endif
#include <Arduino.h>
#include "utils.h"
void logLine(String line, bool newline) {
Serial.print(line);
if(newline) {
Serial.println();
}
}
#ifndef UTILS_H
#define UTILS_H
#include <Arduino.h>
void logLine(String line, bool newline = true);
#endif
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment