Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Added ESP32 support, slider, color, dropdown, toggle controls and som… … 10658fc …e other bonuses #44

Closed
wants to merge 10 commits into from

Conversation

aaronse
Copy link

@aaronse aaronse commented Oct 26, 2020

No description provided.

@aaronse
Copy link
Author

aaronse commented Oct 26, 2020

Example UI and associated config definition:

image

[
    {
        "name": "hostName",
        "label": "Host Name",
        "type": "char",
        "length": 32,
        "value": "Haptic-01"
    },
    {
        "name": "projectName",
        "label": "Project Name",
        "type": "char",
        "length": 32,
        "value": "Haptic Light ESP8266"
    },
    {
        "name": "mode",
        "label": "Mode",
        "type": "char",
        "length": 20,
        "inputControl": "select",
        "value": "Aurora",
        "options": [
            "Aurora",
            "Blue",
            "Blue Wave",
            "Custom Color",
            "Custom Wave",
            "Sunset",
            "Ocean",
            "Rainbow",
            "White",
            "White Wave"
        ]
    },
    {
        "name": "brightness",
        "label": "Brightness",
        "type": "uint8_t",
        "inputControl": "slider",
        "value": 25,
        "min": 1,
        "max": 100
    },
    {
        "name": "nightBrightness",
        "label": "Night Brightness",
        "type": "uint8_t",
        "inputControl": "slider",
        "value": 20,
        "min": 1,
        "max": 100
    },
    {
        "name": "isActive",
        "label": "Is Active",
        "type": "bool",
        "value": true
    },
    {
        "name": "isPlaying",
        "label": "Is Animated",
        "type": "bool",
        "value": true
    },
    {
        "name": "color",
        "label": "Custom Color",
        "type": "char",
        "length": 11,
        "inputControl": "color",
        "value": "#ff00ff"
    },
    {
        "name": "speed",
        "label": "Speed",
        "type": "uint8_t",
        "inputControl": "slider",
        "value": 23,
        "min": 1,
        "max": 200
    },
    {
        "name": "isPirSensorEnabled",
        "label": "Auto Motion detection",
        "type": "bool",
        "value": true
    },
    {
        "name": "pirActiveTimeoutSecs",
        "label": "Auto light timeout secs",
        "type": "uint16_t",
        "inputControl": "slider",
        "value": 60,
        "min": 10,
        "max": 300
    },
    {
        "name": "isLuxSensorEnabled",
        "label": "Auto LUX brightness",
        "type": "bool",
        "value": true
    },
    {
        "name": "isTempSensorEnabled",
        "label": "Detect Temp/Humidity",
        "type": "bool",
        "value": false
    },
    {
        "name": "pixelCount",
        "label": "LED count",
        "type": "uint16_t",
        "value": 110,
        "min": 10,
        "max": 300
    },
    {
        "name": "dummyFloat",
        "type": "float",
        "hidden": true,
        "min": 1,
        "max": 10,
        "value": 1.2345
    },
    {
        "name": "dummyString",
        "type": "char",
        "length": 11,
        "hidden": true,
        "value": "invisible!"
    }
]

@aaronse
Copy link
Author

aaronse commented Oct 26, 2020

Am investigating and fixing ESLint related failures @ https://travis-ci.com/github/maakbaas/esp8266-iot-framework/jobs/407066412

@aaronse
Copy link
Author

aaronse commented Oct 26, 2020

@maakbaas, please let me know what you think of how the additional UI controls can be used.

If you agree with the approach, after accommodating feedback from you (and others), I'll push another commit with usage information added to https://github.com/maakbaas/esp8266-iot-framework/blob/master/docs/config-manager.md

@maakbaas
Copy link
Owner

@aaronse thanks for the major contributions in this pull request!

The combination of items makes it a bit difficult to review and make it ready to merge. Can you please split this in a stacked or multiple pull requests? That would be really appreciated.

  • ESP32 changes should be a separate pull request. I see there are also still quite some gaps in functionality on the ESP32 side. This should be investigated further or resolved before it can be merged to the master. For now I am ok with the SSL functionality missing on the ESP32 side, but all the rest should be fully functional.

  • Input control should be a separate pull request. I really like the approach for being able to define what control type a configuration item should have in the GUI, great idea. The only change I would propose is to use native UI checkbox and slider elements instead of react-toggle and react-slider. Personally I think we should keep the memory footprint on the ESP as small as possible. And indeed, changes to the documentation should be included in the pull request to keep the docs up to date.

  • Some changes should not be included in the pull request, such as the changes to your platformio.ini, the addition of esp8266-iot.code-workspace, and the addition of asn1crypto to packages.json?

  • what is the purpose of bool config::hasConfigChanged()?

@aaronse
Copy link
Author

aaronse commented Oct 30, 2020

Hello @maakbaas! Quick update since am away for a few days. Totally understand about single pull request being tricky to review.

Am splitting the ESP32 and Input Control changes to separate pull requests. Will submit Input Control pull request first, is more complete and would immediately help folks with similar requirements to me.

wrt ESP32 edits, you're right. A bunch of functionality was not ported. I only ported the functionality immediately needed for projects am actively working on. Was hoping to either get around to fleshing out the remaining work, or rely on someone else to step in that needs those edits more urgently than me.

Thanks for the feedback about misc unrequired edits, fixing/fixed those.

hasConfigChanged was a simple hook added to enable my calling app to determine whether the Web User edited/saved the config. My calling app's loop() does something different if the config was changed. A better, longer to implement, alternative considered... Implement some kind of configManager::getConfigHashCode(), or maybe call an existing compute hashcode function in some crypto lib. Computing hash of the config struct's bytes would allow calling apps to detect config changes (because they'd compare last known hashcode), this would also allow calling apps to ignore saves that didn't actually change any setting values.

@maakbaas
Copy link
Owner

maakbaas commented Nov 6, 2020

I will close this pull request for now. Looking forward to the separated items!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants