Add tft.enable flag, gate the use of ILI9341/STMPE610 on it.

- For esp8266 (lightswitch w/o touchscreen), set tft.enable=false
- For esp32 (lightswitch w/ touchscreen), set it to true.

Clean up mos.yml flags per architecture type.
- Button is always 0,2
- Relay0 at 16 for ESP8266, as that's NodeMCU v2's onboard LED.
- Relay0 at 13 for ESP32, as that's Featherwing's onboard LED
This commit is contained in:
Pim van Pelt
2017-12-22 10:23:15 +01:00
parent 44a84dd1bc
commit ecf0a9a2fc
2 changed files with 17 additions and 8 deletions

17
mos.yml
View File

@ -31,8 +31,9 @@ config_schema:
- ["wifi.sta.ssid", "dapches-iot"] - ["wifi.sta.ssid", "dapches-iot"]
- ["wifi.sta.pass", "marielle"] - ["wifi.sta.pass", "marielle"]
- ["tft", "o", {title: "TFT settings"}] - ["tft", "o", {title: "TFT settings"}]
- ["tft.enable", "b", {"title": "Enable STMPE610 and ILI9341"}]
- ["tft.orientation", "i", {title: "Orientation; 0=PORTRAIT 1=LANDSCAPE 2=PORTRAIT_FLIP 3=LANDSCAPE_FLIP"}] - ["tft.orientation", "i", {title: "Orientation; 0=PORTRAIT 1=LANDSCAPE 2=PORTRAIT_FLIP 3=LANDSCAPE_FLIP"}]
- ["tft.orientation", 1 ] - ["tft.orientation", 1]
- ["tft.width", "i", {title: "TFT width in pixels"}] - ["tft.width", "i", {title: "TFT width in pixels"}]
- ["tft.height", "i", {title: "TFT height in pixels"}] - ["tft.height", "i", {title: "TFT height in pixels"}]
- ["tft.width", 480] # Set to 320 for 2.4" Featherwing, set to 480 for 3.5" Featherwing - ["tft.width", 480] # Set to 320 for 2.4" Featherwing, set to 480 for 3.5" Featherwing
@ -45,11 +46,8 @@ config_schema:
- ["app.inactivity_timeout", "i", {title: "Inactivity timeout in seconds"}] - ["app.inactivity_timeout", "i", {title: "Inactivity timeout in seconds"}]
- ["app.inactivity_timeout", 10] - ["app.inactivity_timeout", 10]
- ["app.battery_calibration", i, {title: "Battery ADC value at 4000mV"}] - ["app.battery_calibration", i, {title: "Battery ADC value at 4000mV"}]
- ["app.battery_calibration", 2360]
- ["app.buttons", "s", {title: "comma-separated list of button pins"}] - ["app.buttons", "s", {title: "comma-separated list of button pins"}]
- ["app.buttons", "0,2"]
- ["app.relays", "s", {title: "comma-separated list of relay pins"}] - ["app.relays", "s", {title: "comma-separated list of relay pins"}]
- ["app.relays", "16,12,13,14"]
- ["spi.enable", true] - ["spi.enable", true]
- ["spi.cs1_gpio", -1] - ["spi.cs1_gpio", -1]
- ["spi.cs2_gpio", -1] - ["spi.cs2_gpio", -1]
@ -77,11 +75,20 @@ conds:
- ["spi.cs1_gpio", 32] # STMPE610 - ["spi.cs1_gpio", 32] # STMPE610
- ["ili9341.dc_pin", 33] - ["ili9341.dc_pin", 33]
- ["stmpe610.irq_pin", 23] - ["stmpe610.irq_pin", 23]
- ["tft.enable", true]
- ["app.buttons", "0,2"]
- ["app.relays", "13,12,14,16"]
- ["tft.enable", true]
- ["app.battery_calibration", 2360]
- when: mos.platform == "esp8266" - when: mos.platform == "esp8266"
apply: apply:
build_vars: build_vars:
MGOS_PLATFORM_ESP8266: 1 MGOS_PLATFORM_ESP8266: 1
config_schema:
- ["tft.enable", false]
- ["app.buttons", "0,2"]
- ["app.relays", "16,12,13,14"]
- ["app.battery_calibration", -1]
# List of libraries used by this app, in order of initialisation # List of libraries used by this app, in order of initialisation

View File

@ -47,7 +47,7 @@ static void touch_handler(struct mgos_stmpe610_event_data *ed) {
} }
} }
void tft_demo(void) static void tft_init(void)
{ {
mgos_ili9341_set_dimensions(mgos_sys_config_get_tft_width(), mgos_sys_config_get_tft_height()); mgos_ili9341_set_dimensions(mgos_sys_config_get_tft_width(), mgos_sys_config_get_tft_height());
mgos_ili9341_set_rotation(mgos_sys_config_get_tft_orientation()); mgos_ili9341_set_rotation(mgos_sys_config_get_tft_orientation());
@ -65,6 +65,8 @@ void tft_demo(void)
screen_add_default_widgets(s_screen); screen_add_default_widgets(s_screen);
screen_widget_broadcast(s_screen, EV_WIDGET_DRAW, NULL); screen_widget_broadcast(s_screen, EV_WIDGET_DRAW, NULL);
LOG(LL_INFO, ("Screen '%s' has %d widgets", s_screen->name, screen_get_num_widgets(s_screen))); LOG(LL_INFO, ("Screen '%s' has %d widgets", s_screen->name, screen_get_num_widgets(s_screen)));
backlight_init();
} }
enum mgos_app_init_result mgos_app_init(void) enum mgos_app_init_result mgos_app_init(void)
@ -73,9 +75,9 @@ enum mgos_app_init_result mgos_app_init(void)
relays_init(mgos_sys_config_get_app_relays()); relays_init(mgos_sys_config_get_app_relays());
mqtt_init(); mqtt_init();
rpc_init(); rpc_init();
backlight_init();
tft_demo(); if (mgos_sys_config_get_tft_enable())
tft_init();
return MGOS_APP_INIT_SUCCESS; return MGOS_APP_INIT_SUCCESS;
} }