Skip to content
Open
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
59 changes: 0 additions & 59 deletions examples/Locker/locker-sketch.ino

This file was deleted.

95 changes: 0 additions & 95 deletions examples/My9231Lamp/My9231Lamp.ino

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This is a part of the Uniot project.
* Copyright (C) 2016-2023 Uniot <contact@uniot.io>
* Copyright (C) 2016-2025 Uniot <contact@uniot.io>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
17 changes: 11 additions & 6 deletions examples/My9231Lamp/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@
; https://docs.platformio.org/page/projectconf.html

[env:esp12e]
platform = espressif8266@4.2.1
platform = espressif8266
framework = arduino
board = sonoff_basic
board_build.filesystem = littlefs
monitor_speed = 115200
monitor_filters = default, esp8266_exception_decoder
extra_scripts = ./scripts/download_fs.py

lib_deps =
./../uniot-cbor
./../uniot-lisp
./../uniot-pubsubclient
./../uniot-crypto
uniot-io/uniot-core@^0.8.1

build_unflags =
-std=gnu++11

build_flags =
-std=gnu++17
-D UNIOT_CREATOR_ID=\"UNIOT\"
-D UNIOT_LOG_ENABLED=1
-D UNIOT_USE_LITTLEFS=1
-D UNIOT_LOG_LEVEL=UNIOT_LOG_LEVEL_DEBUG
-D UNIOT_LISP_HEAP=10000
-D MQTT_MAX_PACKET_SIZE=2048
87 changes: 87 additions & 0 deletions examples/My9231Lamp/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* This is a part of the Uniot project.
* Copyright (C) 2016-2025 Uniot <contact@uniot.io>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <Uniot.h>
#include <My9231Lamp.h>

using namespace uniot;

My9231Lamp Lamp;

// Custom Lisp primitive to control the lamp
Object lamp_update(Root root, VarObject env, VarObject list) {
auto expeditor = PrimitiveExpeditor::describe("lamp_update", Lisp::Bool, 5, Lisp::Int, Lisp::Int, Lisp::Int, Lisp::Int, Lisp::Int)
.init(root, env, list);
expeditor.assertDescribedArgs();

// Get RGB, warm white, and cool white values
auto red = expeditor.getArgInt(0);
auto green = expeditor.getArgInt(1);
auto blue = expeditor.getArgInt(2);
auto warm = expeditor.getArgInt(3);
auto cool = expeditor.getArgInt(4);

// Clamp values to valid range
red = std::min(255, std::max(0, red));
green = std::min(255, std::max(0, green));
blue = std::min(255, std::max(0, blue));
warm = std::min(255, std::max(0, warm));
cool = std::min(255, std::max(0, cool));

// Note: For Sonoff B1R2, you may need to adjust:
// warm = warm > 0 ? 255 : 0;
// cool = cool > 0 ? 255 : 0;

// Update the lamp
Lamp.off();
Lamp.set(red, green, blue, warm, cool);
Lamp.update();

return expeditor.makeBool(true);
}

void setup() {
// Initialize the lamp
Lamp.off();

// Custom WiFi status LED handler that uses the lamp
Uniot.addWifiStatusLedListener([](bool state) {
Lamp.off();
Lamp.setRed(state ? 10 : 0);
Lamp.update();
});

// Add custom Lisp primitive for lamp control
Uniot.addLispPrimitive(lamp_update);

// Create periodic tasks for monitoring
Uniot.setInterval([]() {
UNIOT_LOG_DEBUG("Free heap: %u", ESP.getFreeHeap());
}, 5000);

Uniot.setInterval([]() {
UNIOT_LOG_DEBUG("Time: %s", Date::getFormattedTime().c_str());
}, 5000);

// Initialize and start Uniot
Uniot.begin();
}

void loop() {
Uniot.loop();
}
41 changes: 0 additions & 41 deletions examples/S20Socket/S20Socket.ino

This file was deleted.

17 changes: 11 additions & 6 deletions examples/S20Socket/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@
; https://docs.platformio.org/page/projectconf.html

[env:esp12e]
platform = espressif8266@4.2.1
platform = espressif8266
framework = arduino
board = sonoff_basic
board_build.filesystem = littlefs
monitor_speed = 115200
monitor_filters = default, esp8266_exception_decoder
extra_scripts = ./scripts/download_fs.py

lib_deps =
./../uniot-cbor
./../uniot-lisp
./../uniot-pubsubclient
./../uniot-crypto
uniot-io/uniot-core@^0.8.1

build_unflags =
-std=gnu++11

build_flags =
-std=gnu++17
-D UNIOT_CREATOR_ID=\"UNIOT\"
-D UNIOT_LOG_ENABLED=1
-D UNIOT_USE_LITTLEFS=1
-D UNIOT_LOG_LEVEL=UNIOT_LOG_LEVEL_DEBUG
-D UNIOT_LISP_HEAP=10000
-D MQTT_MAX_PACKET_SIZE=2048
Loading