|
|
|
@ -7,8 +7,7 @@ local display = require("display") |
|
|
|
|
local controls = require("controls") |
|
|
|
|
local bluetooth = require("bluetooth") |
|
|
|
|
local database = require("database") |
|
|
|
|
|
|
|
|
|
local settings = {} |
|
|
|
|
local screen = require("screen") |
|
|
|
|
|
|
|
|
|
local function SettingsScreen(title) |
|
|
|
|
local menu = widgets.MenuScreen { |
|
|
|
@ -31,10 +30,11 @@ local function SettingsScreen(title) |
|
|
|
|
return menu |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function settings.bluetooth() |
|
|
|
|
local menu = SettingsScreen("Bluetooth") |
|
|
|
|
local BluetoothSettings = screen:new { |
|
|
|
|
createUi = function(self) |
|
|
|
|
self.menu = SettingsScreen("Bluetooth") |
|
|
|
|
|
|
|
|
|
local enable_container = menu.content:Object { |
|
|
|
|
local enable_container = self.menu.content:Object { |
|
|
|
|
flex = { |
|
|
|
|
flex_direction = "row", |
|
|
|
|
justify_content = "flex-start", |
|
|
|
@ -52,12 +52,12 @@ function settings.bluetooth() |
|
|
|
|
bluetooth.enabled:set(enabled) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
menu.content:Label { |
|
|
|
|
self.menu.content:Label { |
|
|
|
|
text = "Paired Device", |
|
|
|
|
pad_bottom = 1, |
|
|
|
|
}:add_style(theme.settings_title) |
|
|
|
|
|
|
|
|
|
local paired_container = menu.content:Object { |
|
|
|
|
local paired_container = self.menu.content:Object { |
|
|
|
|
flex = { |
|
|
|
|
flex_direction = "row", |
|
|
|
|
justify_content = "flex-start", |
|
|
|
@ -78,17 +78,17 @@ function settings.bluetooth() |
|
|
|
|
bluetooth.paired_device:set() |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
menu.content:Label { |
|
|
|
|
self.menu.content:Label { |
|
|
|
|
text = "Nearby Devices", |
|
|
|
|
pad_bottom = 1, |
|
|
|
|
}:add_style(theme.settings_title) |
|
|
|
|
|
|
|
|
|
local devices = menu.content:List { |
|
|
|
|
local devices = self.menu.content:List { |
|
|
|
|
w = lvgl.PCT(100), |
|
|
|
|
h = lvgl.SIZE_CONTENT, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
menu.bindings = { |
|
|
|
|
self.bindings = { |
|
|
|
|
bluetooth.enabled:bind(function(en) |
|
|
|
|
if en then |
|
|
|
|
enable_sw:add_state(lvgl.STATE.CHECKED) |
|
|
|
@ -115,15 +115,17 @@ function settings.bluetooth() |
|
|
|
|
end) |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function settings.headphones() |
|
|
|
|
local menu = SettingsScreen("Headphones") |
|
|
|
|
local HeadphonesSettings = screen:new { |
|
|
|
|
createUi = function(self) |
|
|
|
|
self.menu = SettingsScreen("Headphones") |
|
|
|
|
|
|
|
|
|
menu.content:Label { |
|
|
|
|
self.menu.content:Label { |
|
|
|
|
text = "Maximum volume limit", |
|
|
|
|
}:add_style(theme.settings_title) |
|
|
|
|
|
|
|
|
|
local volume_chooser = menu.content:Dropdown { |
|
|
|
|
local volume_chooser = self.menu.content:Dropdown { |
|
|
|
|
options = "Line Level (-10 dB)\nCD Level (+6 dB)\nMaximum (+10dB)", |
|
|
|
|
selected = 1, |
|
|
|
|
} |
|
|
|
@ -134,11 +136,11 @@ function settings.headphones() |
|
|
|
|
volume.limit_db:set(limits[selection]) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
menu.content:Label { |
|
|
|
|
self.menu.content:Label { |
|
|
|
|
text = "Left/Right balance", |
|
|
|
|
}:add_style(theme.settings_title) |
|
|
|
|
|
|
|
|
|
local balance = menu.content:Slider { |
|
|
|
|
local balance = self.menu.content:Slider { |
|
|
|
|
w = lvgl.PCT(100), |
|
|
|
|
h = 5, |
|
|
|
|
range = { min = -100, max = 100 }, |
|
|
|
@ -148,9 +150,9 @@ function settings.headphones() |
|
|
|
|
volume.left_bias:set(balance:value()) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
local balance_label = menu.content:Label {} |
|
|
|
|
local balance_label = self.menu.content:Label {} |
|
|
|
|
|
|
|
|
|
menu.bindings = { |
|
|
|
|
self.bindings = { |
|
|
|
|
volume.limit_db:bind(function(limit) |
|
|
|
|
for i = 1, #limits do |
|
|
|
|
if limits[i] == limit then |
|
|
|
@ -175,14 +177,14 @@ function settings.headphones() |
|
|
|
|
end |
|
|
|
|
end), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return menu |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function settings.display() |
|
|
|
|
local menu = SettingsScreen("Display") |
|
|
|
|
local DisplaySettings = screen:new { |
|
|
|
|
createUi = function(self) |
|
|
|
|
self.menu = SettingsScreen("Display") |
|
|
|
|
|
|
|
|
|
local brightness_title = menu.content:Object { |
|
|
|
|
local brightness_title = self.menu.content:Object { |
|
|
|
|
flex = { |
|
|
|
|
flex_direction = "row", |
|
|
|
|
justify_content = "flex-start", |
|
|
|
@ -196,7 +198,7 @@ function settings.display() |
|
|
|
|
local brightness_pct = brightness_title:Label {} |
|
|
|
|
brightness_pct:add_style(theme.settings_title) |
|
|
|
|
|
|
|
|
|
local brightness = menu.content:Slider { |
|
|
|
|
local brightness = self.menu.content:Slider { |
|
|
|
|
w = lvgl.PCT(100), |
|
|
|
|
h = 5, |
|
|
|
|
range = { min = 0, max = 100 }, |
|
|
|
@ -206,19 +208,19 @@ function settings.display() |
|
|
|
|
display.brightness:set(brightness:value()) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
menu.bindings = { |
|
|
|
|
self.bindings = { |
|
|
|
|
display.brightness:bind(function(b) |
|
|
|
|
brightness_pct:set { text = tostring(b) .. "%" } |
|
|
|
|
end) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return menu |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function settings.input() |
|
|
|
|
local menu = SettingsScreen("Input Method") |
|
|
|
|
local InputSettings = screen:new { |
|
|
|
|
createUi = function(self) |
|
|
|
|
self.menu = SettingsScreen("Input Method") |
|
|
|
|
|
|
|
|
|
menu.content:Label { |
|
|
|
|
self.menu.content:Label { |
|
|
|
|
text = "Control scheme", |
|
|
|
|
}:add_style(theme.settings_title) |
|
|
|
|
|
|
|
|
@ -239,11 +241,11 @@ function settings.input() |
|
|
|
|
option_idx = option_idx + 1 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local controls_chooser = menu.content:Dropdown { |
|
|
|
|
local controls_chooser = self.menu.content:Dropdown { |
|
|
|
|
options = options, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
menu.bindings = { |
|
|
|
|
self.bindings = { |
|
|
|
|
controls.scheme:bind(function(s) |
|
|
|
|
local option = scheme_to_option[s] |
|
|
|
|
controls_chooser:set({ selected = option }) |
|
|
|
@ -256,12 +258,12 @@ function settings.input() |
|
|
|
|
controls.scheme:set(scheme) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
menu.content:Label { |
|
|
|
|
self.menu.content:Label { |
|
|
|
|
text = "Scroll Sensitivity", |
|
|
|
|
}:add_style(theme.settings_title) |
|
|
|
|
|
|
|
|
|
local slider_scale = 4; -- Power steering |
|
|
|
|
local sensitivity = menu.content:Slider { |
|
|
|
|
local sensitivity = self.menu.content:Slider { |
|
|
|
|
w = lvgl.PCT(90), |
|
|
|
|
h = 5, |
|
|
|
|
range = { min = 0, max = 255 / slider_scale }, |
|
|
|
@ -270,17 +272,17 @@ function settings.input() |
|
|
|
|
sensitivity:onevent(lvgl.EVENT.VALUE_CHANGED, function() |
|
|
|
|
controls.scroll_sensitivity:set(sensitivity:value() * slider_scale) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
return menu |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function settings.database() |
|
|
|
|
local menu = SettingsScreen("Database") |
|
|
|
|
local DatabaseSettings = screen:new { |
|
|
|
|
createUi = function(self) |
|
|
|
|
self.menu = SettingsScreen("Database") |
|
|
|
|
local db = require("database") |
|
|
|
|
widgets.Row(menu.content, "Schema version", db.version()) |
|
|
|
|
widgets.Row(menu.content, "Size on disk", string.format("%.1f KiB", db.size() / 1024)) |
|
|
|
|
widgets.Row(self.menu.content, "Schema version", db.version()) |
|
|
|
|
widgets.Row(self.menu.content, "Size on disk", string.format("%.1f KiB", db.size() / 1024)) |
|
|
|
|
|
|
|
|
|
local actions_container = menu.content:Object { |
|
|
|
|
local actions_container = self.menu.content:Object { |
|
|
|
|
w = lvgl.PCT(100), |
|
|
|
|
h = lvgl.SIZE_CONTENT, |
|
|
|
|
flex = { |
|
|
|
@ -300,54 +302,59 @@ function settings.database() |
|
|
|
|
database.update() |
|
|
|
|
end) |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function settings.firmware() |
|
|
|
|
local menu = SettingsScreen("Firmware") |
|
|
|
|
local FirmwareSettings = screen:new { |
|
|
|
|
createUi = function(self) |
|
|
|
|
self.menu = SettingsScreen("Firmware") |
|
|
|
|
local version = require("version") |
|
|
|
|
widgets.Row(menu.content, "ESP32", version.esp()) |
|
|
|
|
widgets.Row(menu.content, "SAMD21", version.samd()) |
|
|
|
|
widgets.Row(menu.content, "Collator", version.collator()) |
|
|
|
|
widgets.Row(self.menu.content, "ESP32", version.esp()) |
|
|
|
|
widgets.Row(self.menu.content, "SAMD21", version.samd()) |
|
|
|
|
widgets.Row(self.menu.content, "Collator", version.collator()) |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function settings.root() |
|
|
|
|
local menu = widgets.MenuScreen { |
|
|
|
|
local LicensesScreen = screen:new { |
|
|
|
|
createUi = function(self) |
|
|
|
|
self.root = require("licenses")() |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return screen:new { |
|
|
|
|
createUi = function(self) |
|
|
|
|
self.menu = widgets.MenuScreen { |
|
|
|
|
show_back = true, |
|
|
|
|
title = "Settings", |
|
|
|
|
} |
|
|
|
|
menu.list = menu.root:List { |
|
|
|
|
self.list = self.menu.root:List { |
|
|
|
|
w = lvgl.PCT(100), |
|
|
|
|
h = lvgl.PCT(100), |
|
|
|
|
flex_grow = 1, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
local function section(name) |
|
|
|
|
menu.list:add_text(name):add_style(theme.list_heading) |
|
|
|
|
self.list:add_text(name):add_style(theme.list_heading) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local function submenu(name, fn) |
|
|
|
|
local item = menu.list:add_btn(nil, name) |
|
|
|
|
local function submenu(name, class) |
|
|
|
|
local item = self.list:add_btn(nil, name) |
|
|
|
|
item:onClicked(function() |
|
|
|
|
backstack.push(fn) |
|
|
|
|
backstack.push(class:new()) |
|
|
|
|
end) |
|
|
|
|
item:add_style(theme.list_item) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
section("Audio") |
|
|
|
|
submenu("Bluetooth", settings.bluetooth) |
|
|
|
|
submenu("Headphones", settings.headphones) |
|
|
|
|
submenu("Bluetooth", BluetoothSettings) |
|
|
|
|
submenu("Headphones", HeadphonesSettings) |
|
|
|
|
|
|
|
|
|
section("Interface") |
|
|
|
|
submenu("Display", settings.display) |
|
|
|
|
submenu("Input Method", settings.input) |
|
|
|
|
submenu("Display", DisplaySettings) |
|
|
|
|
submenu("Input Method", InputSettings) |
|
|
|
|
|
|
|
|
|
section("System") |
|
|
|
|
submenu("Database", settings.database) |
|
|
|
|
submenu("Firmware", settings.firmware) |
|
|
|
|
submenu("Licenses", function() |
|
|
|
|
return require("licenses")() |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
return menu |
|
|
|
|
submenu("Database", DatabaseSettings) |
|
|
|
|
submenu("Firmware", FirmwareSettings) |
|
|
|
|
submenu("Licenses", LicensesScreen) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return settings |
|
|
|
|
} |
|
|
|
|