Compare commits
6 Commits
984a429cc0
...
old-graph-
| Author | SHA1 | Date | |
|---|---|---|---|
| 26839b82b7 | |||
| 6cd7d7db29 | |||
| 17c559a31f | |||
| e6ba60da89 | |||
| 8bf174d256 | |||
| 5f9f508581 |
2
.gitignore
vendored
@@ -10,5 +10,5 @@
|
|||||||
**/Makefile
|
**/Makefile
|
||||||
**/*.cbp
|
**/*.cbp
|
||||||
**/node-modules/
|
**/node-modules/
|
||||||
**/CmakeLists.txt.user
|
**/CMakeLists.txt.user
|
||||||
**/catch2/bin/
|
**/catch2/bin/
|
||||||
|
|||||||
11
README.md
@@ -2,15 +2,16 @@
|
|||||||
|
|
||||||
This repository is a collection of useful code snippets and configurations.
|
This repository is a collection of useful code snippets and configurations.
|
||||||
|
|
||||||
```
|
```bash
|
||||||
github.com/shaunrd0/klips/
|
shaunrd0/klips/
|
||||||
├── ansible # Ansible roles, playbooks, and examples
|
├── ansible # Ansible roles, playbooks, and examples
|
||||||
├── blockchain # Blockchain related project templates and examples
|
├── blockchain # Blockchain related project templates and examples
|
||||||
├── cpp # C++ programs, datastructures, and other examples
|
├── cpp # C++ programs, datastructures, and other examples
|
||||||
├── dotnet # .NET projects and examples
|
├── dotnet # .NET projects and examples
|
||||||
|
├── esp # ESP32 projects and examples
|
||||||
├── figlet # Figlet fonts I like :)
|
├── figlet # Figlet fonts I like :)
|
||||||
├── javascript # Javascript projects and examples
|
├── javascript # Javascript projects and examples
|
||||||
├── python # Python scripts or tools I've made
|
├── python # Python scripts and tools I've made
|
||||||
├── README.md
|
├── scripts # Bash scripts
|
||||||
└── scripts # Bash scripts
|
└── README.md
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Ansible
|
# ansible
|
||||||
|
|
||||||
A few simple roles / plays I've put together in learning how to use Ansible can be found under their corresponding directories.
|
A few simple roles / plays I've put together in learning how to use Ansible can be found under their corresponding directories.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# blockchain
|
||||||
|
|
||||||
A template project for getting started working on the Ethereum blockchain.
|
A template project for getting started working on the Ethereum blockchain.
|
||||||
This project comes with basic packages for compiling and deploying Solidity contracts with Truffle.
|
This project comes with basic packages for compiling and deploying Solidity contracts with Truffle.
|
||||||
@@ -72,7 +73,7 @@ I explain how to configure metamask on ropsten on [Knoats - Solidity](https://kn
|
|||||||
|
|
||||||
Give yourself test Ethereum with the [Ropsten ETH Faucet](https://faucet.ropsten.be)
|
Give yourself test Ethereum with the [Ropsten ETH Faucet](https://faucet.ropsten.be)
|
||||||
|
|
||||||
To deploy to ropsten test network, and verify using `truffle-verify-plugin` -
|
To deploy to ropsten test network, and verify using `truffle-verify-plugin` -
|
||||||
|
|
||||||
```asm
|
```asm
|
||||||
npx truffle migrate --network ropsten
|
npx truffle migrate --network ropsten
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Cpp
|
# cpp
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
shaunrd0/klips/cpp/
|
shaunrd0/klips/cpp/
|
||||||
@@ -13,11 +13,11 @@ shaunrd0/klips/cpp/
|
|||||||
└── README.md
|
└── README.md
|
||||||
```
|
```
|
||||||
|
|
||||||
This directory contains a `CMakeLists.txt`, which can be selected to open as a
|
This directory contains a `CMakeLists.txt`, which can be selected to open as a
|
||||||
project within your preferred IDE. From there, all nested examples can be built,
|
project within your preferred IDE. From there, all nested examples can be built,
|
||||||
debugged, and ran.
|
debugged, and ran.
|
||||||
|
|
||||||
Some of the more recent projects in this repository requires the latest CMake LTS.
|
Some of the more recent projects in this repository requires the latest CMake LTS.
|
||||||
To install `cmake` LTS with `apt` we can follow [official instructions from kitware](https://apt.kitware.com/)
|
To install `cmake` LTS with `apt` we can follow [official instructions from kitware](https://apt.kitware.com/)
|
||||||
Alternatively, we can install the LTS with python's `pip`.
|
Alternatively, we can install the LTS with python's `pip`.
|
||||||
```bash
|
```bash
|
||||||
@@ -34,7 +34,7 @@ cmake version 3.22.1
|
|||||||
|
|
||||||
Once cmake is installed, dependencies for all examples can be installed with the command below.
|
Once cmake is installed, dependencies for all examples can be installed with the command below.
|
||||||
```bash
|
```bash
|
||||||
sudo apt install libsdl2-dev freeglut3-dev
|
sudo apt install libsdl2-dev freeglut3-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
If we build from this directory, we build all C++ projects and examples
|
If we build from this directory, we build all C++ projects and examples
|
||||||
@@ -63,7 +63,7 @@ graph-test-object sdl-test visitor-test
|
|||||||
graph-test-simple select-sort
|
graph-test-simple select-sort
|
||||||
```
|
```
|
||||||
|
|
||||||
We can also build from subdirectories.
|
We can also build from subdirectories.
|
||||||
To only build projects related to design patterns we build from the `patterns/` subdirectory, for example
|
To only build projects related to design patterns we build from the `patterns/` subdirectory, for example
|
||||||
```bash
|
```bash
|
||||||
cd /path/to/klips/cpp/patterns
|
cd /path/to/klips/cpp/patterns
|
||||||
@@ -80,5 +80,5 @@ adapter-test factory-test prototype-test state-test
|
|||||||
|
|
||||||
If cmake is not being used in a project, it can be built with `g++` manually using
|
If cmake is not being used in a project, it can be built with `g++` manually using
|
||||||
the commands outlined in `*/.vscode/tasks.json`, or by using VSCode to open the example
|
the commands outlined in `*/.vscode/tasks.json`, or by using VSCode to open the example
|
||||||
and running the build task.
|
and running the build task.
|
||||||
Check the header comments in the main source file for the example for instructions.
|
Check the header comments in the main source file for the example for instructions.
|
||||||
|
|||||||
21
cpp/problems/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
################################################################################
|
||||||
|
## Author: Shaun Reed ##
|
||||||
|
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||||
|
## About: A root project for C++ practice problems and solutions ##
|
||||||
|
## ##
|
||||||
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
project(
|
||||||
|
#[[NAME]] Problems
|
||||||
|
VERSION 1.0
|
||||||
|
DESCRIPTION "Practice problems and solutions written in C++"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY, ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
add_compile_options("-Wall")
|
||||||
|
|
||||||
|
add_subdirectory(graphs)
|
||||||
24
cpp/problems/README.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Problems
|
||||||
|
|
||||||
|
A collection of some example problems and solutions written in C++. Mostly these
|
||||||
|
are based off questions I found on [hackerrank](https://www.hackerrank.com),
|
||||||
|
[leetcode](https://leetcode.com/), [codility](https://www.codility.com/), or
|
||||||
|
similar programming practice platforms.
|
||||||
|
|
||||||
|
```
|
||||||
|
klips/cpp/problems
|
||||||
|
.
|
||||||
|
├── graphs # Graph implementations with related problems and solutions
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
We can build the examples with the following commands.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /path/to/klips/cpp/problems/
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake .. && cmake --build .
|
||||||
|
ls bin/
|
||||||
|
|
||||||
|
problems-graphs
|
||||||
|
```
|
||||||
21
cpp/problems/graphs/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
################################################################################
|
||||||
|
## Author: Shaun Reed ##
|
||||||
|
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||||
|
## About: Collection of problems and solutions to graph problems in C++ ##
|
||||||
|
## ##
|
||||||
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
project(
|
||||||
|
#[[NAME]] ProblemsGraphs
|
||||||
|
VERSION 1.0
|
||||||
|
DESCRIPTION "Problems and solutions using graphs in C++"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
add_compile_options("-Wall")
|
||||||
|
|
||||||
|
add_executable(problems-graphs driver.cpp lib-graph.cpp lib-graph.hpp)
|
||||||
32
cpp/problems/graphs/driver.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*##############################################################################
|
||||||
|
## Author: Shaun Reed ##
|
||||||
|
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||||
|
## About: Driver program solving various C++ graph problems ##
|
||||||
|
## ##
|
||||||
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||||
|
################################################################################
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "lib-graph.hpp"
|
||||||
|
|
||||||
|
int main(const int argc, const char * argv[]) {
|
||||||
|
Simple::Graph g({ {1,2,3}, {2,3,4} });
|
||||||
|
g.Print();
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
std::vector<int> graphA = {6,0,1,2,3,4,5};
|
||||||
|
std::vector<std::pair<int, int>> graphB = { {9, 2}, {2, 3}, {3, 1} };
|
||||||
|
std::vector<std::vector<int>> graphC = {{1}, {2, 3}, {3, 1, 0}};
|
||||||
|
g.ReadEdges(graphA);
|
||||||
|
g.Print();
|
||||||
|
std::cout << std::endl;
|
||||||
|
g.ReadEdges(graphB);
|
||||||
|
g.Print();
|
||||||
|
std::cout << std::endl;
|
||||||
|
g.ReadEdges(graphC);
|
||||||
|
g.Print();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
12
cpp/problems/graphs/lib-graph.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*##############################################################################
|
||||||
|
## Author: Shaun Reed ##
|
||||||
|
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||||
|
## About: Graph implementations to solve various problems in C++ ##
|
||||||
|
## ##
|
||||||
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||||
|
################################################################################
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "lib-graph.hpp"
|
||||||
|
|
||||||
|
|
||||||
335
cpp/problems/graphs/lib-graph.hpp
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
/*##############################################################################
|
||||||
|
## Author: Shaun Reed ##
|
||||||
|
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||||
|
## About: Graph implementations to solve various problems in C++ ##
|
||||||
|
## ##
|
||||||
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||||
|
################################################################################
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <map>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#ifndef GRAPHS_LIB_GRAPH_HPP
|
||||||
|
#define GRAPHS_LIB_GRAPH_HPP
|
||||||
|
|
||||||
|
|
||||||
|
namespace Simple {
|
||||||
|
typedef int32_t Node;
|
||||||
|
typedef std::vector<Node> Nodes;
|
||||||
|
typedef std::vector<Nodes> Edges;
|
||||||
|
|
||||||
|
class Graph {
|
||||||
|
public:
|
||||||
|
Graph() = default;
|
||||||
|
explicit Graph(Edges e) : edges(std::move(e)) { }
|
||||||
|
|
||||||
|
void Print()
|
||||||
|
{
|
||||||
|
for (size_t node = 0; node < edges.size(); node++) {
|
||||||
|
for (const auto & to : edges[node]) {
|
||||||
|
std::cout << "(" << node << ")-----(" << to << ")" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where graph[i] represents the connection between node i and graph[i]
|
||||||
|
// {1, 1, 2, 2}
|
||||||
|
void ReadEdges(const std::vector<int> & graph)
|
||||||
|
{
|
||||||
|
edges.clear();
|
||||||
|
edges.assign(graph.size(), {});
|
||||||
|
for (int i = 0; i < graph.size(); i++) {
|
||||||
|
if (i == graph[i]) continue;
|
||||||
|
edges[graph[i]].push_back(i);
|
||||||
|
edges[i].push_back(graph[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where each graph[i] represents a single edge between two nodes
|
||||||
|
// { {1, 2}, {2, 3}, {3, 1} }
|
||||||
|
void ReadEdges(const std::vector<std::pair<int, int>> & graph)
|
||||||
|
{
|
||||||
|
edges.clear();
|
||||||
|
for (const auto & edge : graph) {
|
||||||
|
while (edges.size() <= edge.first || edges.size() <= edge.second) {
|
||||||
|
edges.emplace_back();
|
||||||
|
}
|
||||||
|
edges[edge.first].push_back(edge.second);
|
||||||
|
edges[edge.second].push_back(edge.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where graph[node] holds all connected adjacent nodes
|
||||||
|
// {{1}, {2, 3}, {2, 1, 0}}
|
||||||
|
void ReadEdges(const std::vector<std::vector<int>> & graph)
|
||||||
|
{
|
||||||
|
edges.clear();
|
||||||
|
edges.assign(graph.size(), {});
|
||||||
|
for (size_t i = 0; i < graph.size(); i++) {
|
||||||
|
for (const auto & adj : graph[i]) {
|
||||||
|
if (adj == i) continue;
|
||||||
|
edges[i].push_back(adj);
|
||||||
|
edges[adj].push_back(int32_t(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Edges edges;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Object {
|
||||||
|
struct Node {
|
||||||
|
Node() : val(INT32_MIN), adj() { }
|
||||||
|
explicit Node(int32_t v) : val(v), adj() { }
|
||||||
|
Node(int32_t v, std::vector<int32_t> a) : val(v), adj(std::move(a)) { }
|
||||||
|
|
||||||
|
int32_t val;
|
||||||
|
std::vector<int32_t> adj;
|
||||||
|
|
||||||
|
// Define operator== for std::find; And comparisons between nodes
|
||||||
|
bool operator==(const Node & b) const { return this->val == b.val;}
|
||||||
|
bool operator!=(const Node & b) const { return this->val != b.val;}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<Node> Edges;
|
||||||
|
|
||||||
|
class Graph {
|
||||||
|
public:
|
||||||
|
Graph() = default;
|
||||||
|
explicit Graph(Edges e) : edges(std::move(e)) { }
|
||||||
|
|
||||||
|
void Print()
|
||||||
|
{
|
||||||
|
for (int32_t node = 0; node < edges.size(); node++) {
|
||||||
|
for (const auto & to : GetNode(node)->adj) {
|
||||||
|
std::cout << "(" << node << ")-----(" << to << ")" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Node * GetNode(const int32_t & nodeVal)
|
||||||
|
{
|
||||||
|
auto foundNode = std::find(edges.begin(), edges.end(), Node(nodeVal));
|
||||||
|
// [nodeVal](const Node & a)->bool { return a.val == nodeVal;});
|
||||||
|
if (foundNode == edges.end()) return nullptr; // Node does not exist
|
||||||
|
return &*foundNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node * CreateNode(const int32_t & nodeVal)
|
||||||
|
{
|
||||||
|
auto newNode = GetNode(nodeVal);
|
||||||
|
if (newNode != nullptr) return newNode;
|
||||||
|
// Create node if not found
|
||||||
|
edges.emplace_back(nodeVal); // Calls Node(int32_t) ctor
|
||||||
|
return &edges.back(); // Get ptr to our new node; Don't copy it
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where graph[i] represents the connection between node i and graph[i]
|
||||||
|
// {1, 1, 2, 2}
|
||||||
|
void ReadEdges(const std::vector<int> & graph)
|
||||||
|
{
|
||||||
|
edges.clear();
|
||||||
|
for (int i = 0; i < graph.size(); i++) {
|
||||||
|
if (i == graph[i]) continue;
|
||||||
|
// Check if nodes already exist; Create them if not found
|
||||||
|
auto nodeFrom = CreateNode(graph[i]);
|
||||||
|
auto nodeTo = CreateNode(i);
|
||||||
|
// Push node ptr to adjacent list
|
||||||
|
nodeFrom->adj.push_back(nodeTo->val);
|
||||||
|
nodeTo->adj.push_back(nodeFrom->val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where each graph[i] represents a single edge between two nodes
|
||||||
|
// { {1, 2}, {2, 3}, {3, 1} }
|
||||||
|
void ReadEdges(const std::vector<std::pair<int, int>> & graph)
|
||||||
|
{
|
||||||
|
edges.clear();
|
||||||
|
for (const auto & edge : graph) {
|
||||||
|
auto nodeFrom = CreateNode(edge.first);
|
||||||
|
auto nodeTo = CreateNode(edge.second);
|
||||||
|
nodeFrom->adj.push_back(nodeTo->val);
|
||||||
|
nodeTo->adj.push_back(nodeFrom->val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where graph[node] holds all connected adjacent nodes
|
||||||
|
// {{1}, {2, 3}, {2, 1, 0}}
|
||||||
|
void ReadEdges(const std::vector<std::vector<int>> & graph)
|
||||||
|
{
|
||||||
|
edges.clear();
|
||||||
|
edges.assign(graph.size(), {});
|
||||||
|
for (size_t i = 0; i < graph.size(); i++) {
|
||||||
|
for (const auto & adj : graph[i]) {
|
||||||
|
if (adj == i) continue;
|
||||||
|
auto nodeFrom = CreateNode(int32_t(i));
|
||||||
|
auto nodeTo = CreateNode(adj);
|
||||||
|
nodeFrom->adj.push_back(nodeTo->val);
|
||||||
|
nodeTo->adj.push_back(nodeFrom->val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Edges edges;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Weighted {
|
||||||
|
using Weight = int32_t;
|
||||||
|
using Adjacent = std::multimap<Weight, int32_t>;
|
||||||
|
struct Node {
|
||||||
|
Node() : val(INT32_MIN), adj() { }
|
||||||
|
explicit Node(int32_t v) : val(v), adj() { }
|
||||||
|
Node(int32_t v, Adjacent a) : val(v), adj(std::move(a)) { }
|
||||||
|
|
||||||
|
int32_t val;
|
||||||
|
Adjacent adj;
|
||||||
|
};
|
||||||
|
using Edge = std::pair<int, int>;
|
||||||
|
|
||||||
|
class Graph {
|
||||||
|
Graph() = default;
|
||||||
|
explicit Graph(Node n) : root(std::move(n)) { }
|
||||||
|
void ReadGraph(std::vector<std::vector<int>> nodeList)
|
||||||
|
{
|
||||||
|
// Read a 2D vector of nodes into a
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Node root;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//namespace Object {
|
||||||
|
//struct Edge {
|
||||||
|
// friend struct Node;
|
||||||
|
// friend class Graph;
|
||||||
|
// Edge() : from(INT32_MIN), to(INT32_MIN) { }
|
||||||
|
// Edge(const int32_t & f, const int32_t & t) : from(f), to(t) { }
|
||||||
|
//
|
||||||
|
// private:
|
||||||
|
// int32_t from, to;
|
||||||
|
// };
|
||||||
|
// using Edges = std::vector<Edge>;
|
||||||
|
//
|
||||||
|
//// template <typename T, typename S>
|
||||||
|
//// struct Subscriptor {
|
||||||
|
//// T<int32_t, S> data;
|
||||||
|
//// };
|
||||||
|
//
|
||||||
|
// struct Node {
|
||||||
|
// using Adjacent = std::vector<Node *>;
|
||||||
|
// using NodeMap = std::unordered_map<int32_t, Node *>;
|
||||||
|
// friend class Graph; // Allow Graph to access protected / private members
|
||||||
|
// friend struct GraphData;
|
||||||
|
//
|
||||||
|
// // Struct is public by default
|
||||||
|
// Node () : val(0), adj() { }
|
||||||
|
// explicit Node(int32_t v) : val(v), adj() { }
|
||||||
|
// Node(int32_t v, Adjacent a) : val(v), adj(std::move(a)) { }
|
||||||
|
// inline void SetAdjacent(Adjacent a) { adj = std::move(a);}
|
||||||
|
// inline void SetVal(int32_t v) { val = v;}
|
||||||
|
// NodeMap GetNodeMap() {
|
||||||
|
// NodeMap result;
|
||||||
|
// BuildNodeMap(&result);
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// void BuildNodeMap(NodeMap & nodeMap, Node * startNode=nullptr) {
|
||||||
|
// auto list = startNode == nullptr ? adj : startNode->adj;
|
||||||
|
// for (const auto & node : list) {
|
||||||
|
// if (!nodeMap.count(node->val)) {
|
||||||
|
// nodeMap[node->val] = node;
|
||||||
|
// BuildNodeMap(nodeMap, startNode);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// protected:
|
||||||
|
// int32_t val;
|
||||||
|
// Adjacent adj;
|
||||||
|
// Edges edges;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct GraphData {
|
||||||
|
// GraphData() = default;
|
||||||
|
// explicit GraphData(const Node & n)
|
||||||
|
// {
|
||||||
|
// graphEdges n.edges;
|
||||||
|
// for (const auto & edge : n.edges) {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Implement subscript operators for unordered_multimap
|
||||||
|
// struct GraphEdges {
|
||||||
|
// Edges * operator[](int32_t nodeVal) {
|
||||||
|
// auto found = graphEdges.find(nodeVal):
|
||||||
|
// if (found != graphEdges.end()) {
|
||||||
|
// return &*found->second;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// return nullptr;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// std::unordered_multimap<int32_t, Edges *> graphEdges;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// // Implement subscript operators for unordered_map
|
||||||
|
// struct GraphNodes {
|
||||||
|
// Node * operator[](int32_t nodeVal) {
|
||||||
|
// auto found = graphNodes.find(nodeVal):
|
||||||
|
// if (found != graphNodes.end()) {
|
||||||
|
// return &*found->second;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// return nullptr;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// std::unordered_map<int32_t, Node *> graphNodes;
|
||||||
|
// };
|
||||||
|
// // unordered_* provides O(1) access and search
|
||||||
|
// GraphEdges graphEdges;
|
||||||
|
// GraphNodes graphNodes;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// class Graph {
|
||||||
|
// // Class is private by default
|
||||||
|
// Node root;
|
||||||
|
// std::unordered_map<int32_t, Node *> graphNodes;
|
||||||
|
// std::multimap<int32_t, Edges> graphEdges;
|
||||||
|
//// std::unordered_map<int32_t, Node *> graphNodes;
|
||||||
|
//// GraphData data; // Struct containing all graph edges / nodes
|
||||||
|
//
|
||||||
|
// public:
|
||||||
|
// Graph() = default;
|
||||||
|
// explicit Graph(Node r) : root(std::move(r)) { }
|
||||||
|
//
|
||||||
|
// inline const Node & GetRoot() const { return root;}
|
||||||
|
//// inline Node * GetNode(int32_t nodeVal) { return data.graphNodes[nodeVal];}
|
||||||
|
//// inline const Node * GetConstNode(int32_t nodeVal)
|
||||||
|
//// { return data.graphNodes[nodeVal];}
|
||||||
|
//
|
||||||
|
// const Node * DFS(int32_t nodeVal, int32_t startNode=INT32_MIN)
|
||||||
|
// {
|
||||||
|
// // If startNode was not set, begin search from root node
|
||||||
|
// startNode = startNode == INT32_MIN ? root.val : startNode;
|
||||||
|
// if (startNode == nodeVal) {
|
||||||
|
// return graphNodes[nodeVal];
|
||||||
|
// }
|
||||||
|
// for (const auto & edge : root.edges) {
|
||||||
|
// return DFS(nodeVal, edge.to);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//}
|
||||||
|
|
||||||
|
#endif // GRAPHS_LIB_GRAPH_HPP
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE QtCreatorProject>
|
|
||||||
<!-- Written by QtCreator 9.0.1, 2022-12-24T09:28:53. -->
|
|
||||||
<qtcreator>
|
|
||||||
<data>
|
|
||||||
<variable>EnvironmentId</variable>
|
|
||||||
<value type="QByteArray">{ce8a8d3d-318d-4c62-a573-71d1755252ce}</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
|
||||||
<value type="qlonglong">0</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
|
||||||
<value type="QString" key="language">Cpp</value>
|
|
||||||
<valuemap type="QVariantMap" key="value">
|
|
||||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
|
||||||
<value type="QString" key="language">QmlJS</value>
|
|
||||||
<valuemap type="QVariantMap" key="value">
|
|
||||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
|
||||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
|
||||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
|
||||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
|
||||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
|
||||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
|
||||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
|
||||||
<valuemap type="QVariantMap" key="ClangTools">
|
|
||||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
|
||||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
|
||||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
|
||||||
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
|
||||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="QString" key="DeviceType">Desktop</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 6.3.1 GCC 64bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 6.3.1 GCC 64bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{70d5e2e6-ad48-44fa-b4dd-c54058c4b48b}</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
|
||||||
<value type="QString" key="CMake.Build.Type">Debug</value>
|
|
||||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=Debug
|
|
||||||
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
|
||||||
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
|
||||||
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
|
||||||
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
|
|
||||||
<value type="QString" key="CMake.Source.Directory">/home/kapper/Code/klips/cpp/qt/designer-plugin-collection</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kapper/Code/klips/cpp/qt/designer-plugin-collection/cmake-build-debug</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
|
||||||
<value type="QString">all</value>
|
|
||||||
</valuelist>
|
|
||||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
|
||||||
<value type="QString">clean</value>
|
|
||||||
</valuelist>
|
|
||||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
|
||||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
|
||||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">widget-app</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.widget-app</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">widget-app</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/kapper/Code/klips/cpp/qt/designer-plugin-collection/cmake-build-debug</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
|
||||||
<value type="qlonglong">1</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
|
||||||
<value type="int">22</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>Version</variable>
|
|
||||||
<value type="int">22</value>
|
|
||||||
</data>
|
|
||||||
</qtcreator>
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE QtCreatorProject>
|
|
||||||
<!-- Written by QtCreator 9.0.1, 2022-12-24T09:58:46. -->
|
|
||||||
<qtcreator>
|
|
||||||
<data>
|
|
||||||
<variable>EnvironmentId</variable>
|
|
||||||
<value type="QByteArray">{ce8a8d3d-318d-4c62-a573-71d1755252ce}</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
|
||||||
<value type="qlonglong">0</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
|
||||||
<value type="QString" key="language">Cpp</value>
|
|
||||||
<valuemap type="QVariantMap" key="value">
|
|
||||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
|
||||||
<value type="QString" key="language">QmlJS</value>
|
|
||||||
<valuemap type="QVariantMap" key="value">
|
|
||||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
|
||||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
|
||||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
|
||||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
|
||||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
|
||||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
|
||||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
|
||||||
<valuemap type="QVariantMap" key="ClangTools">
|
|
||||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
|
||||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
|
||||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
|
||||||
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
|
||||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="QString" key="DeviceType">Desktop</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 6.3.1 GCC 64bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 6.3.1 GCC 64bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{70d5e2e6-ad48-44fa-b4dd-c54058c4b48b}</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
|
||||||
<value type="QString" key="CMake.Build.Type">Debug</value>
|
|
||||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=Debug
|
|
||||||
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
|
||||||
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
|
||||||
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
|
||||||
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
|
|
||||||
<value type="QString" key="CMake.Source.Directory">/home/kapper/Code/klips/cpp/qt/designer-plugin</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kapper/Code/klips/cpp/qt/designer-plugin/cmake-build-debug</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
|
||||||
<value type="QString">all</value>
|
|
||||||
</valuelist>
|
|
||||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
|
||||||
<value type="QString">clean</value>
|
|
||||||
</valuelist>
|
|
||||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
|
||||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
|
||||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">widget-app</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.widget-app</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">widget-app</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/kapper/Code/klips/cpp/qt/designer-plugin/cmake-build-debug</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
|
||||||
<value type="qlonglong">1</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
|
||||||
<value type="int">22</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>Version</variable>
|
|
||||||
<value type="int">22</value>
|
|
||||||
</data>
|
|
||||||
</qtcreator>
|
|
||||||
@@ -1,189 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE QtCreatorProject>
|
|
||||||
<!-- Written by QtCreator 8.0.1, 2022-12-18T08:59:41. -->
|
|
||||||
<qtcreator>
|
|
||||||
<data>
|
|
||||||
<variable>EnvironmentId</variable>
|
|
||||||
<value type="QByteArray">{ce8a8d3d-318d-4c62-a573-71d1755252ce}</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
|
||||||
<value type="qlonglong">0</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
|
||||||
<value type="QString" key="language">Cpp</value>
|
|
||||||
<valuemap type="QVariantMap" key="value">
|
|
||||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
|
||||||
<value type="QString" key="language">QmlJS</value>
|
|
||||||
<valuemap type="QVariantMap" key="value">
|
|
||||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
|
||||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
|
||||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
|
||||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
|
||||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
|
||||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
|
||||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
|
||||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
|
||||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
|
||||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
|
||||||
<valuemap type="QVariantMap" key="ClangTools">
|
|
||||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
|
||||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
|
||||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
|
||||||
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
|
||||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
|
||||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
|
||||||
</valuemap>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value type="QString" key="DeviceType">Desktop</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 6.3.1 GCC 64bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 6.3.1 GCC 64bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{6ade7dd7-47b1-42f6-b09c-570bb7fbeb1c}</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
|
||||||
<value type="QString" key="CMake.Build.Type">Debug</value>
|
|
||||||
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=Debug
|
|
||||||
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
|
|
||||||
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
|
||||||
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
|
||||||
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
|
||||||
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
|
|
||||||
<value type="QString" key="CMake.Source.Directory">/home/kapper/Code/klips/cpp/qt/designer</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kapper/Code/klips/cpp/qt/designer/cmake-build-debug</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
|
||||||
<value type="QString">all</value>
|
|
||||||
</valuelist>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
|
||||||
</valuemap>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
|
||||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
|
||||||
<value type="QString">clean</value>
|
|
||||||
</valuelist>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
|
||||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
|
||||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
|
||||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">designer</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.designer</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">designer</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/kapper/Code/klips/cpp/qt/designer/cmake-build-debug</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
|
||||||
<value type="qlonglong">1</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
|
||||||
<value type="int">22</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>Version</variable>
|
|
||||||
<value type="int">22</value>
|
|
||||||
</data>
|
|
||||||
</qtcreator>
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Dotnet
|
# dotnet
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
shaunrd0/klips/dotnet/
|
shaunrd0/klips/dotnet/
|
||||||
|
|||||||
38
esp/cpp/01_led-button/01_led-button.ino
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
// set pin numbers
|
||||||
|
const int buttonPin = 4; // the number of the pushbutton pin
|
||||||
|
const int ledPin = 5; // the number of the LED pin
|
||||||
|
|
||||||
|
// variable for storing the pushbutton status
|
||||||
|
int buttonState = 0;
|
||||||
|
|
||||||
|
bool light_on = false;
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
// initialize the pushbutton pin as an input
|
||||||
|
pinMode(buttonPin, INPUT);
|
||||||
|
// initialize the LED pin as an output
|
||||||
|
pinMode(ledPin, OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// read the state of the pushbutton value
|
||||||
|
buttonState = digitalRead(buttonPin);
|
||||||
|
// check if the pushbutton is pressed.
|
||||||
|
if (buttonState == HIGH) {
|
||||||
|
if (!handled) {
|
||||||
|
Serial.println("Handling button pressed.");
|
||||||
|
light_on = !light_on;
|
||||||
|
handled = true;
|
||||||
|
digitalWrite(ledPin, light_on ? HIGH : LOW);
|
||||||
|
}
|
||||||
|
// turn LED on
|
||||||
|
} else {
|
||||||
|
if (handled) {
|
||||||
|
Serial.println("Reset button handled state.");
|
||||||
|
handled = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
esp/cpp/01_led-button/README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# 01_led-button
|
||||||
|
|
||||||
|
This example is largely adapted from those in [ESP32-basic-starter-kit.pdf](./ESP32-basic-starter-kit.pdf).
|
||||||
|
|
||||||
|
The APIs in the original examples paired with this PDF have changed, and I decided to do some different things with the code and/or circuits, but the original code can be [found here](https://www.dropbox.com/scl/fo/6znlij3eb23ih4jxcpv2w/AKvB1t9CCUgoVRVtGen8Yrw?rlkey=z84anl0hs940qf9fpl7l8q8q2&e=1&dl=0).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Simple LED controlled by an on-board button.
|
||||||
BIN
esp/cpp/01_led-button/schematic.png
Normal file
|
After Width: | Height: | Size: 304 KiB |
183
esp/cpp/02_led-button-web/02_led-button-web.ino
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
#include <WiFi.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Web server project globals
|
||||||
|
|
||||||
|
// Replace with your network credentials
|
||||||
|
const char* ssid = "network-name";
|
||||||
|
const char* password = "password";
|
||||||
|
|
||||||
|
WiFiServer server(80);
|
||||||
|
|
||||||
|
// Variable to store the HTTP request
|
||||||
|
String header;
|
||||||
|
|
||||||
|
// Current time
|
||||||
|
unsigned long currentTime = millis();
|
||||||
|
// Previous time
|
||||||
|
unsigned long previousTime = 0;
|
||||||
|
// Define timeout time in milliseconds (example: 2000ms = 2s)
|
||||||
|
const long timeoutTime = 2000;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Button / light project globals
|
||||||
|
|
||||||
|
// set pin numbers
|
||||||
|
const int buttonPin = 4; // the number of the pushbutton pin
|
||||||
|
const int ledPin = 5; // the number of the LED pin
|
||||||
|
|
||||||
|
// variable for storing the pushbutton status
|
||||||
|
int buttonState = 0;
|
||||||
|
|
||||||
|
bool light_on = false;
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
// initialize the pushbutton pin as an input
|
||||||
|
pinMode(buttonPin, INPUT);
|
||||||
|
// initialize the LED pin as an output
|
||||||
|
pinMode(ledPin, OUTPUT);
|
||||||
|
|
||||||
|
// wait for the Serial Monitor to be open
|
||||||
|
while (!Serial) {
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect to Wi-Fi network with SSID and password
|
||||||
|
Serial.print("Connecting to ");
|
||||||
|
Serial.println(ssid);
|
||||||
|
WiFi.begin(ssid, password);
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
// Print local IP address and start web server
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("WiFi connected.");
|
||||||
|
Serial.println("Web Server IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
server.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handles the on-board button press.
|
||||||
|
void handleButtonPress() {
|
||||||
|
// read the state of the pushbutton value
|
||||||
|
buttonState = digitalRead(buttonPin);
|
||||||
|
// check if the pushbutton is pressed.
|
||||||
|
if (buttonState == HIGH) {
|
||||||
|
if (!handled) {
|
||||||
|
Serial.println("Handling button pressed.");
|
||||||
|
light_on = !light_on;
|
||||||
|
handled = true;
|
||||||
|
digitalWrite(ledPin, light_on ? HIGH : LOW);
|
||||||
|
}
|
||||||
|
// turn LED on
|
||||||
|
} else {
|
||||||
|
if (handled) {
|
||||||
|
Serial.println("Reset button handled state.");
|
||||||
|
handled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayPinState(WiFiClient client, int gpio_pin, bool state) {
|
||||||
|
// Display current state, and ON/OFF buttons for GPIO <gpio_pin>
|
||||||
|
client.println(String("<p>GPIO ") + String(gpio_pin) + String(" - Current State ") + String(state ? "ON" : "OFF") + String("</p>"));
|
||||||
|
// If the output state is off, it displays the ON button
|
||||||
|
if (state) {
|
||||||
|
client.println(String("<p><a href=\"/") + String(gpio_pin) + String("/off\"><button class=\"button button2\">OFF</button></a></p>"));
|
||||||
|
} else {
|
||||||
|
client.println(String("<p><a href=\"/") + String(gpio_pin) + String("/on\"><button class=\"button\">ON</button></a></p>"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleStateChange(WiFiClient client, int gpio_pin) {
|
||||||
|
if (header.indexOf(String("GET /") + String(gpio_pin) + String("/on")) >= 0) {
|
||||||
|
Serial.println(String("GPIO ") + String(gpio_pin) + String(" on"));
|
||||||
|
light_on = true;
|
||||||
|
digitalWrite(gpio_pin, HIGH);
|
||||||
|
} else if (header.indexOf(String("GET /") + String(gpio_pin) + String("/off")) >= 0) {
|
||||||
|
Serial.println(String("GPIO ") + String(gpio_pin) + String(" off"));
|
||||||
|
light_on = false;
|
||||||
|
digitalWrite(gpio_pin, LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
WiFiClient client = server.available(); // Listen for incoming clients
|
||||||
|
|
||||||
|
handleButtonPress();
|
||||||
|
|
||||||
|
if (client) { // If a new client connects,
|
||||||
|
currentTime = millis();
|
||||||
|
previousTime = currentTime;
|
||||||
|
Serial.println("New Client."); // print a message out in the serial port
|
||||||
|
Serial.println("Web Server IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
|
String currentLine = ""; // make a String to hold incoming data from the client
|
||||||
|
while (client.connected() && currentTime - previousTime <= timeoutTime) { // loop while the client's connected
|
||||||
|
// Also handle the button press in this loop to not miss events.
|
||||||
|
handleButtonPress();
|
||||||
|
|
||||||
|
currentTime = millis();
|
||||||
|
if (client.available()) { // if there's bytes to read from the client,
|
||||||
|
char c = client.read(); // read a byte, then
|
||||||
|
Serial.write(c); // print it out the serial monitor
|
||||||
|
header += c;
|
||||||
|
if (c == '\n') { // if the byte is a newline character
|
||||||
|
// if the current line is blank, you got two newline characters in a row.
|
||||||
|
// that's the end of the client HTTP request, so send a response:
|
||||||
|
if (currentLine.length() == 0) {
|
||||||
|
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
|
||||||
|
// and a content-type so the client knows what's coming, then a blank line:
|
||||||
|
client.println("HTTP/1.1 200 OK");
|
||||||
|
client.println("Content-type:text/html");
|
||||||
|
client.println("Connection: close");
|
||||||
|
client.println();
|
||||||
|
|
||||||
|
// turns the GPIOs on and off
|
||||||
|
// Display the HTML web page
|
||||||
|
client.println("<!DOCTYPE html><html>");
|
||||||
|
client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
|
||||||
|
client.println("<link rel=\"icon\" href=\"data:,\">");
|
||||||
|
// CSS to style the on/off buttons
|
||||||
|
// Feel free to change the background-color and font-size attributes to fit your preferences
|
||||||
|
client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
|
||||||
|
client.println(".button { background-color: #4CAF50; border: none; color: white; padding: 16px 40px;");
|
||||||
|
client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
|
||||||
|
client.println(".button2 {background-color: #555555;}</style></head>");
|
||||||
|
|
||||||
|
//
|
||||||
|
// Web Page Heading
|
||||||
|
client.println("<body><h1>ESP32 Web Server</h1>");
|
||||||
|
//
|
||||||
|
// Web Page Body Contents
|
||||||
|
|
||||||
|
// Button Controls
|
||||||
|
displayPinState(client, ledPin, light_on);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close Web Page Body / Heading
|
||||||
|
client.println("</body></html>");
|
||||||
|
// The HTTP response ends with another blank line
|
||||||
|
client.println();
|
||||||
|
// Break out of the while loop
|
||||||
|
break;
|
||||||
|
} else { // if you got a newline, then clear currentLine
|
||||||
|
currentLine = "";
|
||||||
|
}
|
||||||
|
} else if (c != '\r') { // if you got anything else but a carriage return character,
|
||||||
|
currentLine += c; // add it to the end of the currentLine
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clear the header variable
|
||||||
|
header = "";
|
||||||
|
// Close the connection
|
||||||
|
client.stop();
|
||||||
|
Serial.println("Client disconnected.");
|
||||||
|
Serial.println("");
|
||||||
|
}
|
||||||
|
}
|
||||||
15
esp/cpp/02_led-button-web/README.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# 02_led-button-web
|
||||||
|
|
||||||
|
This example is largely adapted from those in [ESP32-basic-starter-kit.pdf](./ESP32-basic-starter-kit.pdf).
|
||||||
|
|
||||||
|
The APIs in the original examples paired with this PDF have changed, and I decided to do some different things with the code and/or circuits, but the original code can be [found here](https://www.dropbox.com/scl/fo/6znlij3eb23ih4jxcpv2w/AKvB1t9CCUgoVRVtGen8Yrw?rlkey=z84anl0hs940qf9fpl7l8q8q2&e=1&dl=0).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This example uses the same schematic as [01_led-button](../01_led-button/).
|
||||||
|
|
||||||
|
The only difference is that you can also control the button through a web browser from any device connected to your local network.
|
||||||
|
|
||||||
|
This example was adapted from the example code in the [Arduino ESP32 API reference](https://docs.espressif.com/projects/arduino-esp32/en/latest/api/wifi.html#wi-fi-ap-example).
|
||||||
|
|
||||||
|

|
||||||
BIN
esp/cpp/02_led-button-web/schematic.png
Normal file
|
After Width: | Height: | Size: 304 KiB |
BIN
esp/cpp/02_led-button-web/screenshot.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
161
esp/cpp/03_temp-humidity-web/03_temp-humidity-web.ino
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
// Import required libraries
|
||||||
|
|
||||||
|
#include "WiFi.h"
|
||||||
|
#include "ESPAsyncWebServer.h"
|
||||||
|
#include <Adafruit_Sensor.h>
|
||||||
|
#include <DHT.h>
|
||||||
|
|
||||||
|
// Replace with your network credentials
|
||||||
|
const char* ssid = "network-name";
|
||||||
|
const char* password = "password";
|
||||||
|
|
||||||
|
#define DHTPIN 4 // Digital pin connected to the DHT sensor
|
||||||
|
|
||||||
|
// Uncomment the type of sensor in use:
|
||||||
|
#define DHTTYPE DHT11 // DHT 11
|
||||||
|
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
|
||||||
|
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
|
||||||
|
|
||||||
|
DHT dht(DHTPIN, DHTTYPE);
|
||||||
|
|
||||||
|
// Create AsyncWebServer object on port 80
|
||||||
|
AsyncWebServer server(80);
|
||||||
|
|
||||||
|
String readDHTTemperature() {
|
||||||
|
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
||||||
|
// Read temperature as Celsius (the default)
|
||||||
|
float t = dht.readTemperature();
|
||||||
|
// Read temperature as Fahrenheit (isFahrenheit = true)
|
||||||
|
//float t = dht.readTemperature(true);
|
||||||
|
// Check if any reads failed and exit early (to try again).
|
||||||
|
if (isnan(t)) {
|
||||||
|
Serial.println("Failed to read from DHT sensor!");
|
||||||
|
return "--";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Serial.println(t);
|
||||||
|
return String(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String readDHTHumidity() {
|
||||||
|
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
||||||
|
float h = dht.readHumidity();
|
||||||
|
if (isnan(h)) {
|
||||||
|
Serial.println("Failed to read from DHT sensor!");
|
||||||
|
return "--";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Serial.println(h);
|
||||||
|
return String(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char index_html[] PROGMEM = R"rawliteral(
|
||||||
|
<!DOCTYPE HTML><html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
font-family: Arial;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0px auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
h2 { font-size: 3.0rem; }
|
||||||
|
p { font-size: 3.0rem; }
|
||||||
|
.units { font-size: 1.2rem; }
|
||||||
|
.dht-labels{
|
||||||
|
font-size: 1.5rem;
|
||||||
|
vertical-align:middle;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>ESP32 DHT Server</h2>
|
||||||
|
<p>
|
||||||
|
<i class="fas fa-thermometer-half" style="color:#059e8a;"></i>
|
||||||
|
<span class="dht-labels">Temperature</span>
|
||||||
|
<span id="temperature">%TEMPERATURE%</span>
|
||||||
|
<sup class="units">°C</sup>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<i class="fas fa-tint" style="color:#00add6;"></i>
|
||||||
|
<span class="dht-labels">Humidity</span>
|
||||||
|
<span id="humidity">%HUMIDITY%</span>
|
||||||
|
<sup class="units">%</sup>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
setInterval(function ( ) {
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
document.getElementById("temperature").innerHTML = this.responseText;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.open("GET", "/temperature", true);
|
||||||
|
xhttp.send();
|
||||||
|
}, 10000 ) ;
|
||||||
|
|
||||||
|
setInterval(function ( ) {
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
document.getElementById("humidity").innerHTML = this.responseText;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.open("GET", "/humidity", true);
|
||||||
|
xhttp.send();
|
||||||
|
}, 10000 ) ;
|
||||||
|
</script>
|
||||||
|
</html>)rawliteral";
|
||||||
|
|
||||||
|
// Replaces placeholder with DHT values
|
||||||
|
String processor(const String& var){
|
||||||
|
//Serial.println(var);
|
||||||
|
if(var == "TEMPERATURE"){
|
||||||
|
return readDHTTemperature();
|
||||||
|
}
|
||||||
|
else if(var == "HUMIDITY"){
|
||||||
|
return readDHTHumidity();
|
||||||
|
}
|
||||||
|
return String();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
// Serial port for debugging purposes
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
dht.begin();
|
||||||
|
|
||||||
|
// Connect to Wi-Fi
|
||||||
|
WiFi.begin(ssid, password);
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
delay(1000);
|
||||||
|
Serial.println("Connecting to WiFi..");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print ESP32 Local IP Address
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
|
// Route for root / web page
|
||||||
|
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
|
request->send_P(200, "text/html", index_html, processor);
|
||||||
|
});
|
||||||
|
server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
|
request->send_P(200, "text/plain", readDHTTemperature().c_str());
|
||||||
|
});
|
||||||
|
server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
|
request->send_P(200, "text/plain", readDHTHumidity().c_str());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start server
|
||||||
|
server.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(){
|
||||||
|
|
||||||
|
}
|
||||||
60
esp/cpp/03_temp-humidity-web/README.md
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# 03_temp-humidity-web
|
||||||
|
|
||||||
|
This example is largely adapted from those in [ESP32-basic-starter-kit.pdf](./ESP32-basic-starter-kit.pdf).
|
||||||
|
|
||||||
|
The APIs in the original examples paired with this PDF have changed, and I decided to do some different things with the code and/or circuits, but the original code can be [found here](https://www.dropbox.com/scl/fo/6znlij3eb23ih4jxcpv2w/AKvB1t9CCUgoVRVtGen8Yrw?rlkey=z84anl0hs940qf9fpl7l8q8q2&e=1&dl=0).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Temperature and humidity sensor served on a web page within the local network.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
You need to install a couple of libraries for this project:
|
||||||
|
|
||||||
|
* The DHT and the Adafruit Unified Sensor Driver libraries to read from the DHT sensor.
|
||||||
|
* ESPAsyncWebServer and Async TCP libraries to build the asynchronous web server.
|
||||||
|
|
||||||
|
The default Arduino IDE installation will store libraries at `~/Arduino/ibraries` - if this directory doesn't exist, create it.
|
||||||
|
|
||||||
|
### Installing DHT Sensor Library
|
||||||
|
|
||||||
|
To read from the DHT sensor using Arduino IDE, you need to install the [DHT sensor library](https://github.com/adafruit/DHT-sensor-library).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget -O DHT_sensor.zip https://github.com/adafruit/DHT-sensor-library/archive/master.zip
|
||||||
|
unzip DHT_sensor.zip
|
||||||
|
mv DHT-sensor-library-master/ ~/Arduino/libraries/DHT_sensor
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install Adafruit Unified Sensor Driver Library
|
||||||
|
|
||||||
|
You also need to install the [Adafruit Unified Sensor Driver library](https://github.com/adafruit/Adafruit_Sensor) to work with the DHT sensor.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget -O Adafruit_sensor.zip https://github.com/adafruit/Adafruit_Sensor/archive/master.zip
|
||||||
|
unzip Adafruit_sensor.zip
|
||||||
|
mv Adafruit_Sensor-master/ ~/Arduino/libraries/Adafruit_sensor
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installing ESPAsyncWebServer Library
|
||||||
|
|
||||||
|
Follow the next steps to install the [ESPAsyncWebServer library](https://github.com/me-no-dev/ESPAsyncWebServer):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget -O ESPAsyncWebServer.zip https://github.com/me-no-dev/ESPAsyncWebServer/archive/master.zip
|
||||||
|
unzip ESPAsyncWebServer.zip
|
||||||
|
mv ESPAsyncWebServer-master/ ~/Arduino/libraries/ESPAsyncWebServer
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installing Async TCP Library
|
||||||
|
|
||||||
|
The ESPAsyncWebServer library requires the [AsyncTCP library](https://github.com/me-no-dev/AsyncTCP) to work. Follow the next steps to install that library:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget -O AsyncTCP.zip https://github.com/me-no-dev/AsyncTCP/archive/master.zip
|
||||||
|
unzip AsyncTCP.zip
|
||||||
|
mv AsyncTCP-master/ ~/Arduino/libraries/AsyncTCP
|
||||||
|
```
|
||||||
BIN
esp/cpp/03_temp-humidity-web/schematic.png
Normal file
|
After Width: | Height: | Size: 238 KiB |
BIN
esp/cpp/03_temp-humidity-web/screenshot.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
4
esp/cpp/04_esp-idf-arduino/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
build
|
||||||
|
managed_components
|
||||||
|
dependencies.lock
|
||||||
|
sdkconfig.old
|
||||||
18
esp/cpp/04_esp-idf-arduino/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# For more information about build system see
|
||||||
|
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||||
|
# The following five lines of boilerplate have to be in your project's
|
||||||
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
|
cmake_minimum_required(VERSION 3.26)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
|
project(
|
||||||
|
#[[NAME]] esp-idf-arduino
|
||||||
|
VERSION 0.1
|
||||||
|
DESCRIPTION "Example ESP-IDF cmake project"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
# For writing pure cmake components, see the documentation
|
||||||
|
# https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/build-system.html#writing-pure-cmake-components
|
||||||
|
idf_build_set_property(COMPILE_OPTIONS "-Wno-error" APPEND)
|
||||||
81
esp/cpp/04_esp-idf-arduino/README.md
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# 04_esp-idf-arduino
|
||||||
|
|
||||||
|
There is no schematic for this example, it simply prints some output to the serial monitor at 115200.
|
||||||
|
This is more of a build system example for untethering yourself from the Arduino IDE.
|
||||||
|
|
||||||
|
To build this example you can run the following commands.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# See Dependencies section below for instructions.
|
||||||
|
source ~/path/to/esp-idf/export.sh
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make -j $(nproc)
|
||||||
|
|
||||||
|
# Flash the example to the ESP.
|
||||||
|
make flash
|
||||||
|
|
||||||
|
# Check the serial monitor for 'Hello world!' output.
|
||||||
|
idf.py monitor -b 115200
|
||||||
|
```
|
||||||
|
|
||||||
|
To flash to your ESP or access the `idf.py menuconfig` menu from the ESP-IDF you can run the same commands with `make`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make flash
|
||||||
|
make menuconfig
|
||||||
|
```
|
||||||
|
|
||||||
|
If Ninja is preferred:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -G Nina
|
||||||
|
ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
Install the [ESP-IDF](https://github.com/espressif/esp-idf?tab=readme-ov-file#setup-build-environment)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# https://docs.espressif.com/projects/esp-idf/en/v5.3.2/esp32/get-started/linux-macos-setup.html#for-linux-users
|
||||||
|
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
|
||||||
|
|
||||||
|
git clone -b v5.3.2 --recursive https://github.com/espressif/esp-idf
|
||||||
|
cd esp-idf
|
||||||
|
./install.sh
|
||||||
|
. ./export.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
In CLion there is an official [Serial Monitor](https://plugins.jetbrains.com/plugin/8031-serial-port-monitor) plugin, or use ESP-IDF -
|
||||||
|
|
||||||
|
```bash
|
||||||
|
idf.py monitor -b 115200
|
||||||
|
```
|
||||||
|
|
||||||
|
## Starting Over
|
||||||
|
|
||||||
|
To set up this project from scratch the following commands were used
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# My example project directory
|
||||||
|
cd ~/Code/klips/esp/cpp/04_esp-idf-arduino
|
||||||
|
idf.py set-target esp32
|
||||||
|
idf.py add-dependency "espressif/arduino-esp32^3.1.1"
|
||||||
|
|
||||||
|
# Autostart Arduino for use of `loop()` and `setup()` functions
|
||||||
|
# You can also use the esp-idf `app_main()` function if preferred
|
||||||
|
# https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html#configuration
|
||||||
|
# You can alternatively do this in the GUI tool `idf.py menuconfig`
|
||||||
|
echo "CONFIG_AUTOSTART_ARDUINO=y" >> sdkconfig
|
||||||
|
sed -i -e 's/CONFIG_FREERTOS_HZ=100/CONFIG_FREERTOS_HZ=1000/' sdkconfig
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
idf.py build
|
||||||
|
```
|
||||||
|
|
||||||
|
To set this project up in CLion, see [JetBrains documentation](https://www.jetbrains.com/help/clion/esp-idf.html#env-vars).
|
||||||
4
esp/cpp/04_esp-idf-arduino/main/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
idf_component_register(
|
||||||
|
SRCS "main.cpp"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
)
|
||||||
17
esp/cpp/04_esp-idf-arduino/main/idf_component.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
## IDF Component Manager Manifest File
|
||||||
|
dependencies:
|
||||||
|
## Required IDF version
|
||||||
|
idf:
|
||||||
|
version: '>=4.1.0'
|
||||||
|
# # Put list of dependencies here
|
||||||
|
# # For components maintained by Espressif:
|
||||||
|
# component: "~1.0.0"
|
||||||
|
# # For 3rd party components:
|
||||||
|
# username/component: ">=1.0.0,<2.0.0"
|
||||||
|
# username2/component2:
|
||||||
|
# version: "~1.0.0"
|
||||||
|
# # For transient dependencies `public` flag can be set.
|
||||||
|
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
||||||
|
# # All dependencies of `main` are public by default.
|
||||||
|
# public: true
|
||||||
|
espressif/arduino-esp32: ^3.1.1
|
||||||
10
esp/cpp/04_esp-idf-arduino/main/main.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Serial.println("Hello world!");
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
2405
esp/cpp/04_esp-idf-arduino/sdkconfig
Normal file
4
esp/cpp/05_temp-humidity-web/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
build
|
||||||
|
managed_components
|
||||||
|
dependencies.lock
|
||||||
|
sdkconfig.old
|
||||||
18
esp/cpp/05_temp-humidity-web/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# For more information about build system see
|
||||||
|
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||||
|
# The following five lines of boilerplate have to be in your project's
|
||||||
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
|
cmake_minimum_required(VERSION 3.26)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
|
project(
|
||||||
|
#[[NAME]] temp-humidity-web
|
||||||
|
VERSION 0.1
|
||||||
|
DESCRIPTION "Temperature and humidity from DHT sensor served on a web page"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
# For writing pure cmake components, see the documentation
|
||||||
|
# https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/build-system.html#writing-pure-cmake-components
|
||||||
|
idf_build_set_property(COMPILE_OPTIONS "-Wno-error" APPEND)
|
||||||
27
esp/cpp/05_temp-humidity-web/README.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# 05_temp-humidity-web
|
||||||
|
|
||||||
|
This is the same example in [03_temp-humidity-web](./../03_temp-humidity-web), ported to the cmake ESP-IDF build system.
|
||||||
|
|
||||||
|
For instructions on setting up the ESP-IDF see [04_-esp-idf-arduino](./../04_esp-idf-arduino)
|
||||||
|
|
||||||
|
This example is largely adapted from those in [ESP32-basic-starter-kit.pdf](./ESP32-basic-starter-kit.pdf).
|
||||||
|
|
||||||
|
The APIs in the original examples paired with this PDF have changed, and I decided to do some different things with the code and/or circuits, but the original code can be [found here](https://www.dropbox.com/scl/fo/6znlij3eb23ih4jxcpv2w/AKvB1t9CCUgoVRVtGen8Yrw?rlkey=z84anl0hs940qf9fpl7l8q8q2&e=1&dl=0).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Temperature and humidity sensor served on a web page within the local network.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
To build this example run the following commands.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source ~/path/to/esp-idf/export.sh
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make -j $(nproc)
|
||||||
|
make flash
|
||||||
|
```
|
||||||
4
esp/cpp/05_temp-humidity-web/main/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
idf_component_register(
|
||||||
|
SRCS "main.cpp"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
)
|
||||||
19
esp/cpp/05_temp-humidity-web/main/idf_component.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
## IDF Component Manager Manifest File
|
||||||
|
dependencies:
|
||||||
|
## Required IDF version
|
||||||
|
idf:
|
||||||
|
version: '>=4.1.0'
|
||||||
|
# # Put list of dependencies here
|
||||||
|
# # For components maintained by Espressif:
|
||||||
|
# component: "~1.0.0"
|
||||||
|
# # For 3rd party components:
|
||||||
|
# username/component: ">=1.0.0,<2.0.0"
|
||||||
|
# username2/component2:
|
||||||
|
# version: "~1.0.0"
|
||||||
|
# # For transient dependencies `public` flag can be set.
|
||||||
|
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
||||||
|
# # All dependencies of `main` are public by default.
|
||||||
|
# public: true
|
||||||
|
espressif/arduino-esp32: ^3.1.1
|
||||||
|
zorxx/dht: ^1.0.1
|
||||||
|
esp32async/espasyncwebserver: ^3.7.0~1
|
||||||
189
esp/cpp/05_temp-humidity-web/main/main.cpp
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
#include "WiFi.h"
|
||||||
|
#include "ESPAsyncWebServer.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
// Replace with your network credentials
|
||||||
|
const char *ssid = "wifi";
|
||||||
|
const char *password = "password";
|
||||||
|
|
||||||
|
#define DHTPIN GPIO_NUM_4 // Digital pin connected to the DHT sensor
|
||||||
|
|
||||||
|
// Uncomment the type of sensor in use:
|
||||||
|
#define DHTTYPE DHT_TYPE_DHT11 // DHT 11
|
||||||
|
//#define DHTTYPE DHT_TYPE_DHT22 // DHT 22 (AM2302)
|
||||||
|
//#define DHTTYPE DHT_TYPE_DHT21 // DHT 21 (AM2301)
|
||||||
|
|
||||||
|
float DHT::readTemperature(bool f)
|
||||||
|
{
|
||||||
|
float humidity = 0;
|
||||||
|
float temperature = 0;
|
||||||
|
esp_err_t result = dht_read_float_data(type_, gpio_, &humidity,
|
||||||
|
&temperature);
|
||||||
|
if (result == ESP_OK) {
|
||||||
|
ESP_LOGI("[DHT::readTemperature]", "Humidity: %.1f%% Temperature: %.1f°C",
|
||||||
|
humidity,
|
||||||
|
temperature);
|
||||||
|
} else {
|
||||||
|
ESP_LOGE("[DHT::readTemperature]", "Failed to read sensor data: %s",
|
||||||
|
esp_err_to_name(result));
|
||||||
|
}
|
||||||
|
return f ? (temperature * 1.8f) + 32 : temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
float DHT::readHumidity()
|
||||||
|
{
|
||||||
|
float humidity = 0;
|
||||||
|
float temperature = 0;
|
||||||
|
esp_err_t result = dht_read_float_data(type_, gpio_, &humidity,
|
||||||
|
&temperature);
|
||||||
|
if (result == ESP_OK) {
|
||||||
|
ESP_LOGI("[DHT::readTemperature]", "Humidity: %.1f%% Temperature: %.1f°C",
|
||||||
|
humidity,
|
||||||
|
temperature);
|
||||||
|
} else {
|
||||||
|
ESP_LOGE("[DHT::readTemperature]", "Failed to read sensor data: %s",
|
||||||
|
esp_err_to_name(result));
|
||||||
|
}
|
||||||
|
return humidity;
|
||||||
|
}
|
||||||
|
|
||||||
|
DHT dht(DHTPIN, DHTTYPE);
|
||||||
|
|
||||||
|
// Create AsyncWebServer object on port 80
|
||||||
|
AsyncWebServer server(80);
|
||||||
|
|
||||||
|
String readDHTTemperature()
|
||||||
|
{
|
||||||
|
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
||||||
|
float t = dht.readTemperature();
|
||||||
|
// Check if any reads failed and exit early (to try again).
|
||||||
|
if (isnan(t)) {
|
||||||
|
Serial.println("Failed to read from DHT sensor!");
|
||||||
|
return "--";
|
||||||
|
} else {
|
||||||
|
Serial.println(t);
|
||||||
|
return String(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String readDHTHumidity()
|
||||||
|
{
|
||||||
|
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
||||||
|
float h = dht.readHumidity();
|
||||||
|
if (isnan(h)) {
|
||||||
|
Serial.println("Failed to read from DHT sensor!");
|
||||||
|
return "--";
|
||||||
|
} else {
|
||||||
|
Serial.println(h);
|
||||||
|
return String(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char index_html[] PROGMEM = R"rawliteral(
|
||||||
|
<!DOCTYPE HTML><html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
font-family: Arial;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0px auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
h2 { font-size: 3.0rem; }
|
||||||
|
p { font-size: 3.0rem; }
|
||||||
|
.units { font-size: 1.2rem; }
|
||||||
|
.dht-labels{
|
||||||
|
font-size: 1.5rem;
|
||||||
|
vertical-align:middle;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>ESP32 DHT Server</h2>
|
||||||
|
<p>
|
||||||
|
<i class="fas fa-thermometer-half" style="color:#059e8a;"></i>
|
||||||
|
<span class="dht-labels">Temperature</span>
|
||||||
|
<span id="temperature">%TEMPERATURE%</span>
|
||||||
|
<sup class="units">°C</sup>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<i class="fas fa-tint" style="color:#00add6;"></i>
|
||||||
|
<span class="dht-labels">Humidity</span>
|
||||||
|
<span id="humidity">%HUMIDITY%</span>
|
||||||
|
<sup class="units">%</sup>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
setInterval(function ( ) {
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
document.getElementById("temperature").innerHTML = this.responseText;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.open("GET", "/temperature", true);
|
||||||
|
xhttp.send();
|
||||||
|
}, 10000 ) ;
|
||||||
|
|
||||||
|
setInterval(function ( ) {
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
document.getElementById("humidity").innerHTML = this.responseText;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.open("GET", "/humidity", true);
|
||||||
|
xhttp.send();
|
||||||
|
}, 10000 ) ;
|
||||||
|
</script>
|
||||||
|
</html>)rawliteral";
|
||||||
|
|
||||||
|
// Replaces placeholder with DHT values
|
||||||
|
String processor(const String &var)
|
||||||
|
{
|
||||||
|
//Serial.println(var);
|
||||||
|
if (var == "TEMPERATURE") {
|
||||||
|
return readDHTTemperature();
|
||||||
|
} else if (var == "HUMIDITY") {
|
||||||
|
return readDHTHumidity();
|
||||||
|
}
|
||||||
|
return String();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
// Serial port for debugging purposes
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
// Connect to Wi-Fi
|
||||||
|
WiFi.begin(ssid, password);
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
delay(1000);
|
||||||
|
Serial.println("Connecting to WiFi..");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print ESP32 Local IP Address
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
|
// Route for root / web page
|
||||||
|
server.on("/", HTTP_GET, [ ](AsyncWebServerRequest *request) {
|
||||||
|
request->send(200, "text/html", index_html, processor);
|
||||||
|
});
|
||||||
|
server.on("/temperature", HTTP_GET, [ ](AsyncWebServerRequest *request) {
|
||||||
|
request->send(200, "text/plain", readDHTTemperature().c_str());
|
||||||
|
});
|
||||||
|
server.on("/humidity", HTTP_GET, [ ](AsyncWebServerRequest *request) {
|
||||||
|
request->send(200, "text/plain", readDHTHumidity().c_str());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start server
|
||||||
|
server.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
33
esp/cpp/05_temp-humidity-web/main/main.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef MAIN_H
|
||||||
|
#define MAIN_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "dht.h"
|
||||||
|
|
||||||
|
class DHT {
|
||||||
|
public:
|
||||||
|
DHT(gpio_num_t gpio, dht_sensor_type_t type) :
|
||||||
|
gpio_(gpio), type_(type) { }
|
||||||
|
|
||||||
|
~DHT() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read temperature from DHT sensor
|
||||||
|
*
|
||||||
|
* @param f True to return in Fahrenheit, False for Celsius.
|
||||||
|
*/
|
||||||
|
float readTemperature(bool f = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read humidity from DHT sensor.
|
||||||
|
*/
|
||||||
|
float readHumidity();
|
||||||
|
|
||||||
|
private:
|
||||||
|
gpio_num_t gpio_;
|
||||||
|
dht_sensor_type_t type_;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MAIN_H
|
||||||
BIN
esp/cpp/05_temp-humidity-web/schematic.png
Normal file
|
After Width: | Height: | Size: 238 KiB |
BIN
esp/cpp/05_temp-humidity-web/screenshot.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
2415
esp/cpp/05_temp-humidity-web/sdkconfig
Normal file
BIN
esp/cpp/ESP32-basic-starter-kit.pdf
Normal file
BIN
esp/cpp/ESP32-dev-module.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
20
esp/cpp/README.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# esp
|
||||||
|
|
||||||
|
```bash
|
||||||
|
shaunrd0/klips/esp/
|
||||||
|
├── 01_led-button # Simple LED circuit controlled by an on board button.
|
||||||
|
├── 02_led-button-web # LED controlled by a button or within a web browser.
|
||||||
|
├── 03_temp-humidity-web # Temperature and humidity sensor within a web browser.
|
||||||
|
├── 04_esp-idf-arduino # CMake example instead of Arduino IDE for ESP development.
|
||||||
|
├── 05_temp-humidity-web # Temperature and humidity sensor within a web browser.
|
||||||
|
├── ESP32-basic-starter-kit.pdf # PDF for tutorials in ESP32 starter kit.
|
||||||
|
├── ESP32-dev-module.png
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
Examples 1-3 are built using the Arduino IDE.
|
||||||
|
|
||||||
|
All examples after `04_esp-idf-arduino` are built with cmake and the [ESP-IDF](https://github.com/espressif/esp-idf).
|
||||||
|
|
||||||
|
[Arduino ESP32 GitHub](https://github.com/espressif/arduino-esp32) \
|
||||||
|
[Arduino ESP32 API reference](https://docs.espressif.com/projects/arduino-esp32/en/latest/libraries.html)
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
# Javascript
|
# javascript
|
||||||
|
|
||||||
This directory contains Javascript projects and examples that I've made.
|
This directory contains Javascript projects and examples that I've made.
|
||||||
|
|
||||||
```
|
```bash
|
||||||
github.com/shaunrd0/klips/javascript
|
shaunrd0/klips/javascript
|
||||||
├── webgl # Examples of using WebGL within JS
|
├── webgl # Examples of using WebGL within JS
|
||||||
└── README.md
|
└── README.md
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
|
# python
|
||||||
|
|
||||||
This directory contains a collection of Python scripts or CLI tools that I've made.
|
This directory contains a collection of Python scripts or CLI tools that I've made.
|
||||||
Each of these projects provide a `requirements.txt` that can be used to
|
Each of these projects provide a `requirements.txt` that can be used to
|
||||||
install the required Python packages and dependencies.
|
install the required Python packages and dependencies.
|
||||||
|
|
||||||
To install Python 3.9 and `pip`
|
To install Python 3.9 and `pip`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install python3.9 python3-pip
|
sudo apt install python3.9 python3-pip
|
||||||
python3.9 -m pip install -U pip
|
python3.9 -m pip install -U pip
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||