Skip to content

Instantly share code, notes, and snippets.

Avatar
Expecto Patronum!

Nishan Chathuranga Wickramarathna nishanc

Expecto Patronum!
View GitHub Profile
View save_photo.cpp
static esp_err_t save_photo_numbered()
{
file_number++;
Serial.print("Taking picture: ");
Serial.print(file_number);
camera_fb_t *fb = esp_camera_fb_get();
//char *filename = (char*)malloc(21 + sizeof(int));
char *filename = (char*)malloc(21 + sizeof(file_number));
sprintf(filename, "/sdcard/capture_%d.jpg", file_number);
View save_photo.cpp
void save_photo()
{
if (timeinfo.tm_year < (2016 - 1900) || internet_connected == false) { // if no internet or time not set
save_photo_numbered(); // filenames in numbered order
} else {
save_photo_dated(); // filenames with date and time
}
}
View loop.cpp
void loop() {
current_millis = millis();
if (current_millis - last_capture_millis > capture_interval) { // Take another picture
last_capture_millis = millis();
save_photo();
}
}
View set_time.cpp
void setup() {
// Everything else
startCameraServer();
Serial.print("Camera Ready! Use 'http://");
Serial.print(WiFi.localIP());
Serial.println("' to connect");
View variables.cpp
#include "driver/sdmmc_host.h"
#include "driver/sdmmc_defs.h"
#include "sdmmc_cmd.h"
#include "esp_vfs_fat.h"
long current_millis;
long last_capture_millis = 0;
static esp_err_t cam_err;
static esp_err_t card_err;
View read_from_sd.cpp
//access SD card for WiFi SSID and Password
if (!SD_MMC.begin()) {
Serial.println("Failed to mount card");
return;
}
File file = SD_MMC.open("/ssid.txt", FILE_READ);
File file_pwd = SD_MMC.open("/pwd.txt", FILE_READ);
if (!file || !file_pwd) {
View Results
+--------+----------+---------+---------+-----------+-----------+-----------+-----------+
| Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
+--------+----------+---------+---------+-----------+-----------+-----------+-----------+
| TPH | 132.3 ms | 2.29 ms | 2.03 ms | 8000.0000 | 3000.0000 | 1250.0000 | 44.49 MB |
| TPT | 201.3 ms | 3.32 ms | 3.10 ms | 9000.0000 | 4000.0000 | - | 61.84 MB |
+--------+----------+---------+---------+-----------+-----------+-----------+-----------+
View Script.sql
CREATE TABLE [TPHUsers] (
[Id] int NOT NULL IDENTITY,
[Username] nvarchar(max) NULL,
[Email] nvarchar(max) NULL,
[UserType] nvarchar(max) NOT NULL,
[CGPA] nvarchar(max) NULL,
[Major] nvarchar(max) NULL,
[Designation] nvarchar(max) NULL,
[Speciality] nvarchar(max) NULL,
CONSTRAINT [PK_TPHUsers] PRIMARY KEY ([Id])
View Migration.cs
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TPCStudents",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CGPA = table.Column<string>(type: "nvarchar(max)", nullable: true),
Major = table.Column<string>(type: "nvarchar(max)", nullable: true),
View Script.sql
CREATE TABLE [TPCStudents] (
[Id] int NOT NULL IDENTITY,
[CGPA] nvarchar(max) NULL,
[Major] nvarchar(max) NULL,
[Username] nvarchar(max) NOT NULL,
[Email] nvarchar(max) NOT NULL,
CONSTRAINT [PK_TPCStudents] PRIMARY KEY ([Id])
);
CREATE TABLE [TPCTeachers] (