implement input for custom waterfall colors

This commit is contained in:
Jakob Ketterl 2021-02-16 18:07:13 +01:00
parent 409370aba2
commit 8d2763930b
2 changed files with 24 additions and 0 deletions

View File

@ -9,6 +9,7 @@ from owrx.form import (
DropdownInput, DropdownInput,
Option, Option,
) )
from owrx.form.converter import WaterfallColorsConverter
from owrx.form.receiverid import ReceiverKeysConverter from owrx.form.receiverid import ReceiverKeysConverter
from owrx.form.gfx import AvatarInput, TopPhotoInput from owrx.form.gfx import AvatarInput, TopPhotoInput
from owrx.waterfall import WaterfallOptions from owrx.waterfall import WaterfallOptions
@ -80,6 +81,12 @@ class GeneralSettingsController(SettingsFormController):
"Waterfall color scheme", "Waterfall color scheme",
options=WaterfallOptions, options=WaterfallOptions,
), ),
TextAreaInput(
"waterfall_colors",
"Custom waterfall colors",
infotext="TODO: describe",
converter=WaterfallColorsConverter()
),
NumberInput( NumberInput(
"fft_fps", "fft_fps",
"FFT speed", "FFT speed",

View File

@ -66,3 +66,20 @@ class JsonConverter(Converter):
def convert_from_form(self, value): def convert_from_form(self, value):
return json.loads(value) return json.loads(value)
class WaterfallColorsConverter(Converter):
def convert_to_form(self, value):
if value is None:
return ""
return "\n".join("#{:06x}".format(v) for v in value)
def convert_from_form(self, value):
def parseString(s):
if s.startswith("#"):
return int(s[1:], 16)
# int() with base 0 can accept "0x" prefixed hex strings, or int numbers
return int(s, 0)
# \r\n or \n? this should work with both.
return [parseString(v.strip("\r ")) for v in value.split("\n")]