diff --git a/mos.yml b/mos.yml index c7d5bc3..824866c 100644 --- a/mos.yml +++ b/mos.yml @@ -31,8 +31,9 @@ config_schema: - ["wifi.sta.ssid", "dapches-iot"] - ["wifi.sta.pass", "marielle"] - ["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", 1 ] + - ["tft.orientation", 1] - ["tft.width", "i", {title: "TFT width 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 @@ -45,11 +46,8 @@ config_schema: - ["app.inactivity_timeout", "i", {title: "Inactivity timeout in seconds"}] - ["app.inactivity_timeout", 10] - ["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", "0,2"] - ["app.relays", "s", {title: "comma-separated list of relay pins"}] - - ["app.relays", "16,12,13,14"] - ["spi.enable", true] - ["spi.cs1_gpio", -1] - ["spi.cs2_gpio", -1] @@ -77,11 +75,20 @@ conds: - ["spi.cs1_gpio", 32] # STMPE610 - ["ili9341.dc_pin", 33] - ["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" apply: build_vars: 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 diff --git a/src/main.c b/src/main.c index d201e3e..2059677 100644 --- a/src/main.c +++ b/src/main.c @@ -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_rotation(mgos_sys_config_get_tft_orientation()); @@ -65,6 +65,8 @@ void tft_demo(void) screen_add_default_widgets(s_screen); 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))); + + backlight_init(); } 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()); mqtt_init(); rpc_init(); - backlight_init(); - tft_demo(); + if (mgos_sys_config_get_tft_enable()) + tft_init(); return MGOS_APP_INIT_SUCCESS; }