Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

WIP! Homepoint 2.0 #175

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
[submodule "components/arduino-esp32"]
path = components/arduino-esp32
url = https://github.com/sieren/arduino-esp32.git
[submodule "main/libraries/TFT_eFEX"]
path = main/libraries/TFT_eFEX
url = https://github.com/sieren/TFT_eFEX.git
[submodule "main/libraries/rapidjson"]
path = main/libraries/rapidjson
url = https://github.com/Tencent/rapidjson.git
[submodule "main/libraries/JPEGDecoder"]
path = main/libraries/JPEGDecoder
url = https://github.com/sieren/JPEGDecoder.git
[submodule "components/ESPAsyncWebServer"]
path = components/ESPAsyncWebServer
url = https://github.com/me-no-dev/ESPAsyncWebServer.git
[submodule "components/AsyncTCP"]
path = components/AsyncTCP
url = https://github.com/me-no-dev/AsyncTCP.git
[submodule "main/libraries/TFT_eSPI"]
path = main/libraries/TFT_eSPI
url = https://github.com/Bodmer/TFT_eSPI.git
[submodule "components/lvgl_esp32_drivers"]
path = components/lvgl_esp32_drivers
url = https://github.com/usedbytes/lvgl_esp32_drivers.git
[submodule "components/lvgl"]
path = components/lvgl
url = https://github.com/lvgl/lvgl.git
[submodule "components/axp192"]
path = components/axp192
url = https://github.com/usedbytes/axp192.git
[submodule "components/esp_i2c_helper"]
path = components/esp_i2c_helper
url = https://github.com/tuupola/esp_i2c_helper.git
[submodule "components/esp-rainmaker"]
path = components/esp-rainmaker
url = https://github.com/espressif/esp-rainmaker.git
[submodule "components/esp_littlefs"]
path = components/esp_littlefs
url = https://github.com/joltwallet/esp_littlefs.git
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ install:
# Get required packages - already done above, see addons: apt: packages:
# - sudo apt-get install git wget make libncurses-dev flex bison gperf python python-serial
# Prepare directory for the toolchain
- python3 -m pip || wget -qO- https://bootstrap.pypa.io/pip/3.5/get-pip.py | python3
- mkdir -p ~/esp
- cd ~/esp
# Get ESP-IDF from github
- git clone --recursive https://github.com/espressif/esp-idf.git
- cd esp-idf
- git checkout release/v4.0
- git checkout cf457d41
- git submodule update --init --recursive
- export IDF_PATH=~/esp/esp-idf
- ./install.sh
Expand Down Expand Up @@ -55,7 +56,5 @@ script:
# Update configuration so that kconfig doesn't start interactive mode
- mkdir build
- cd build
- cmake ../
- make -j 8
- cmake -DBOARD=M5STACK ../
- cmake -DBOARD=M5STACKCORE2 ../
- make -j 8
93 changes: 93 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"files.associations": {
"__bit_reference": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__functional_base": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__nullptr": "cpp",
"__split_buffer": "cpp",
"__string": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__tuple": "cpp",
"algorithm": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"exception": "cpp",
"coroutine": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ostream": "cpp",
"queue": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"utility": "cpp",
"variant": "cpp",
"vector": "cpp",
"*.tcc": "cpp",
"memory_resource": "cpp",
"netfwd": "cpp",
"cinttypes": "cpp",
"filesystem": "cpp",
"ranges": "cpp"
}
}
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(CMAKE_CXX_STANDARD 17)
list(APPEND compile_definitions "ARDUINO=202000")


# Ignore warning in Azure IoT Library in esp32 Arduino
# pending PR: https://github.com/VSChina/ESP32_AzureIoT_Arduino/pull/15
list(APPEND compile_options "-Wno-maybe-uninitialized")
list(APPEND EXTRA_COMPONENT_DIRS components/esp-rainmaker/components/ components/lvgl_esp32_drivers components/lvgl_esp32_drivers/lvgl_touch components/lvgl_esp32_drivers/lvgl_tft)


project(homepoint)
23 changes: 22 additions & 1 deletion HomeControl.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,28 @@
"streambuf": "cpp",
"system_error": "cpp",
"thread": "cpp",
"cinttypes": "cpp"
"cinttypes": "cpp",
"bit": "cpp",
"bitset": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"map": "cpp",
"memory_resource": "cpp",
"netfwd": "cpp",
"random": "cpp",
"regex": "cpp",
"string": "cpp",
"iomanip": "cpp",
"iostream": "cpp",
"ranges": "cpp",
"shared_mutex": "cpp",
"stop_token": "cpp",
"variant": "cpp",
"forward_list": "cpp",
"set": "cpp",
"unordered_set": "cpp",
"*.ipp": "cpp"
}
}
}
Binary file modified components/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion components/arduino-esp32
Submodule arduino-esp32 updated 7005 files
1 change: 1 addition & 0 deletions components/axp192
Submodule axp192 added at 99acd4
1 change: 1 addition & 0 deletions components/esp-rainmaker
Submodule esp-rainmaker added at f1b82c
1 change: 1 addition & 0 deletions components/esp_i2c_helper
Submodule esp_i2c_helper added at 6191d4
1 change: 1 addition & 0 deletions components/esp_littlefs
Submodule esp_littlefs added at b58f00
1 change: 1 addition & 0 deletions components/lvgl
Submodule lvgl added at 0bdcf3
1 change: 1 addition & 0 deletions components/lvgl_esp32_drivers
Submodule lvgl_esp32_drivers added at 347aaa
Binary file removed data/arrow_left.jpg
Binary file not shown.
Binary file removed data/arrow_right.jpg
Binary file not shown.
Binary file removed data/bedroom_active.jpg
Binary file not shown.
Binary file removed data/bedroom_inactive.jpg
Binary file not shown.
Binary file removed data/door_active.jpg
Binary file not shown.
Binary file removed data/door_inactive.jpg
Binary file not shown.
Binary file added data/exitbutton.bin
Binary file not shown.
Binary file removed data/fan_active.jpg
Binary file not shown.
Binary file removed data/fan_inactive.jpg
Binary file not shown.
Binary file removed data/fountain_active.jpg
Binary file not shown.
Binary file removed data/fountain_inactive.jpg
Binary file not shown.
Binary file removed data/garden_active.jpg
Binary file not shown.
Binary file removed data/garden_inactive.jpg
Binary file not shown.
Binary file added data/humidity_small.bin
Binary file not shown.
Binary file removed data/humidity_small.jpg
Binary file not shown.
Binary file removed data/kitchen_active.jpg
Binary file not shown.
Binary file removed data/kitchen_inactive.jpg
Binary file not shown.
Binary file removed data/livingroom_active.jpg
Binary file not shown.
Binary file removed data/livingroom_inactive.jpg
Binary file not shown.
Binary file removed data/mqtt_off.jpg
Binary file not shown.
Binary file removed data/mqtt_on.jpg
Binary file not shown.
Binary file removed data/night_active.jpg
Binary file not shown.
Binary file removed data/night_inactive.jpg
Binary file not shown.
Binary file removed data/power_active.jpg
Binary file not shown.
Binary file removed data/power_inactive.jpg
Binary file not shown.
Binary file added data/temperature_small.bin
Binary file not shown.
Binary file removed data/temperature_small.jpg
Binary file not shown.
Binary file added data/voc_small.bin
Binary file not shown.
Binary file removed data/voc_small.jpg
Binary file not shown.
Binary file added data/wattage_small.bin
Binary file not shown.
Binary file removed data/wattage_small.jpg
Diff not rendered.
Binary file removed data/wifi_off.jpg
Diff not rendered.
Binary file removed data/wifi_on.jpg
Diff not rendered.
19 changes: 14 additions & 5 deletions main/AppContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace ctx
void AppContext::setup()
{
fs::FileSystem::getInstance().loadPartitions();
mpWifiContext = std::make_shared<WifiContext>();
try
{
mModel = fs::ConfigReader().readConfiguration();
Expand All @@ -30,9 +31,11 @@ namespace ctx
if (cb == mqtt::MQTTConnectionStatus::CONNECTED)
{
mpMQTTConnection->bindScenes();
mAppStateNotifier.broadcast(ContextState::Ready);
}
});
mpWebServer = std::make_unique<web::WebServer>(shared_from_this(), mModel.mWebCredentials);
mAppStateNotifier.broadcast(ContextState::Ready);
}

void AppContext::reload()
Expand All @@ -52,10 +55,11 @@ namespace ctx
if (cb == mqtt::MQTTConnectionStatus::CONNECTED)
{
mpMQTTConnection->bindScenes();
mAppStateNotifier.broadcast(ContextState::Ready);
}
Serial.println("Connected");
});
mpMQTTConnection->connect();
mAppStateNotifier.broadcast(ContextState::Ready);
}

void AppContext::setFirstLaunch(const WifiCredentials credentials,
Expand All @@ -65,17 +69,22 @@ namespace ctx
ESP.restart();
}

void AppContext::registerStateCallback(AppStateCB callback)
Dispatcher<ctx::ContextState>::CBID AppContext::registerStateCallback(AppStateCB callback)
{
return mAppStateNotifier.addCB(callback);
}

void AppContext::deleteStateCallback(Dispatcher<ctx::ContextState>::CBID callback)
{
mAppStateNotifier.addCB(callback);
mAppStateNotifier.delCB(callback);
}

void AppContext::connectWireless()
{
auto& wifi = mModel.mWifiCredentials;
getWifiContext().connect(wifi.mSSID, wifi.mPassword, wifi.mHostname);
mpWifiContext->connect(wifi.mSSID, wifi.mPassword, wifi.mHostname);
using namespace std::placeholders;
getWifiContext().registerCallback(std::bind(&AppContext::connectionStateChanged, this, _1));
mpWifiContext->registerCallback(std::bind(&AppContext::connectionStateChanged, this, _1));
}

std::vector<MQTTVariants> &AppContext::getMQTTGroups()
Expand Down
7 changes: 4 additions & 3 deletions main/AppContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ namespace ctx
AppContext() = default;
void setup();

WifiContext& getWifiContext() { return mWifiContext; };
std::shared_ptr<WifiContext> getWifiContext() { return mpWifiContext; };
model::Model& getModel() { return mModel; }
std::shared_ptr<mqtt::MQTTConnection> getMQTTConnection() { return mpMQTTConnection; };
std::vector<MQTTVariants> &getMQTTGroups();
void reload();
void connectionStateChanged(ctx::WifiConnectionState state);
void setFirstLaunch(const WifiCredentials credentials,
const std::string login, const std::string username);
void registerStateCallback(AppStateCB callback);
Dispatcher<ctx::ContextState>::CBID registerStateCallback(AppStateCB callback);
void deleteStateCallback(Dispatcher<ctx::ContextState>::CBID callback);

private:
void connectWireless();
Expand All @@ -45,7 +46,7 @@ namespace ctx
std::shared_ptr<ntp::NTPSync> mNTPSync;
std::unique_ptr<wifi::CaptiveServer> mpCaptiveServer;
std::unique_ptr<web::WebServer> mpWebServer;
WifiContext mWifiContext;
std::shared_ptr<WifiContext> mpWifiContext;
rapidjson::Document mConfigDocument;
model::Model mModel;
};
Expand Down
Loading