adding symbol layer. Black code format
This commit is contained in:
parent
767d1b4400
commit
872f7baaa2
2 changed files with 122 additions and 87 deletions
|
|
@ -8,15 +8,23 @@ This version runs on Feather RP2040 with a 3.5" FeatherWing
|
||||||
import time
|
import time
|
||||||
import displayio
|
import displayio
|
||||||
import terminalio
|
import terminalio
|
||||||
from adafruit_display_text import label, bitmap_label
|
from adafruit_display_text import bitmap_label
|
||||||
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
|
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
|
||||||
from touch_deck_layers import touch_deck_config, KEY, STRING, MEDIA, KEY_PRESS, KEY_RELEASE
|
from adafruit_displayio_layout.widgets.icon_widget import IconWidget
|
||||||
|
from adafruit_featherwing import tft_featherwing_35
|
||||||
import usb_hid
|
import usb_hid
|
||||||
from adafruit_hid.keyboard import Keyboard
|
from adafruit_hid.keyboard import Keyboard
|
||||||
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
|
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
|
||||||
from adafruit_hid.consumer_control import ConsumerControl
|
from adafruit_hid.consumer_control import ConsumerControl
|
||||||
from adafruit_displayio_layout.widgets.icon_widget import IconWidget
|
from touch_deck_layers import (
|
||||||
from adafruit_featherwing import tft_featherwing_35
|
touch_deck_config,
|
||||||
|
KEY,
|
||||||
|
STRING,
|
||||||
|
MEDIA,
|
||||||
|
KEY_PRESS,
|
||||||
|
KEY_RELEASE,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# seems to help the touchscreen not get stuck with chip not found
|
# seems to help the touchscreen not get stuck with chip not found
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
@ -53,13 +61,17 @@ display.show(main_group)
|
||||||
loading_group = displayio.Group()
|
loading_group = displayio.Group()
|
||||||
|
|
||||||
# black background, screen size minus side buttons
|
# black background, screen size minus side buttons
|
||||||
loading_background = displayio.Bitmap((display.width-40)//20, display.height//20, 1)
|
loading_background = displayio.Bitmap(
|
||||||
|
(display.width - 40) // 20, display.height // 20, 1
|
||||||
|
)
|
||||||
loading_palette = displayio.Palette(1)
|
loading_palette = displayio.Palette(1)
|
||||||
loading_palette[0] = 0x0
|
loading_palette[0] = 0x0
|
||||||
|
|
||||||
# scaled group to match screen size minus side buttons
|
# scaled group to match screen size minus side buttons
|
||||||
loading_background_scale_group = displayio.Group(scale=20)
|
loading_background_scale_group = displayio.Group(scale=20)
|
||||||
loading_background_tilegrid = displayio.TileGrid(loading_background, pixel_shader=loading_palette)
|
loading_background_tilegrid = displayio.TileGrid(
|
||||||
|
loading_background, pixel_shader=loading_palette
|
||||||
|
)
|
||||||
loading_background_scale_group.append(loading_background_tilegrid)
|
loading_background_scale_group.append(loading_background_tilegrid)
|
||||||
|
|
||||||
# loading screen label
|
# loading screen label
|
||||||
|
|
@ -98,31 +110,19 @@ layer_label.anchored_position = (display.width // 2, 4)
|
||||||
main_group.append(layer_label)
|
main_group.append(layer_label)
|
||||||
|
|
||||||
# right side layer buttons
|
# right side layer buttons
|
||||||
next_layer_btn = IconWidget(
|
next_layer_btn = IconWidget("", "touch_deck_icons/layer_next.bmp", on_disk=True)
|
||||||
"",
|
|
||||||
"touch_deck_icons/layer_next.bmp",
|
|
||||||
on_disk=True
|
|
||||||
)
|
|
||||||
next_layer_btn.x = display.width - 40
|
next_layer_btn.x = display.width - 40
|
||||||
next_layer_btn.y = display.height - 100
|
next_layer_btn.y = display.height - 100
|
||||||
next_layer_btn.resize = (40, 100)
|
next_layer_btn.resize = (40, 100)
|
||||||
main_group.append(next_layer_btn)
|
main_group.append(next_layer_btn)
|
||||||
|
|
||||||
prev_layer_btn = IconWidget(
|
prev_layer_btn = IconWidget("", "touch_deck_icons/layer_prev.bmp", on_disk=True)
|
||||||
"",
|
|
||||||
"touch_deck_icons/layer_prev.bmp",
|
|
||||||
on_disk=True
|
|
||||||
)
|
|
||||||
prev_layer_btn.x = display.width - 40
|
prev_layer_btn.x = display.width - 40
|
||||||
prev_layer_btn.y = 110
|
prev_layer_btn.y = 110
|
||||||
prev_layer_btn.resize = (40, 100)
|
prev_layer_btn.resize = (40, 100)
|
||||||
main_group.append(prev_layer_btn)
|
main_group.append(prev_layer_btn)
|
||||||
|
|
||||||
home_layer_btn = IconWidget(
|
home_layer_btn = IconWidget("", "touch_deck_icons/layer_home.bmp", on_disk=True)
|
||||||
"",
|
|
||||||
"touch_deck_icons/layer_home.bmp",
|
|
||||||
on_disk=True
|
|
||||||
)
|
|
||||||
home_layer_btn.x = display.width - 40
|
home_layer_btn.x = display.width - 40
|
||||||
home_layer_btn.y = 0
|
home_layer_btn.y = 0
|
||||||
home_layer_btn.resize = (40, 100)
|
home_layer_btn.resize = (40, 100)
|
||||||
|
|
@ -202,7 +202,10 @@ while True:
|
||||||
# print(p)
|
# print(p)
|
||||||
|
|
||||||
# Next layer button pressed
|
# Next layer button pressed
|
||||||
if next_layer_btn.contains(p) and NEXT_LAYER_INDEX not in _pressed_icons:
|
if (
|
||||||
|
next_layer_btn.contains(p)
|
||||||
|
and NEXT_LAYER_INDEX not in _pressed_icons
|
||||||
|
):
|
||||||
|
|
||||||
# increment layer
|
# increment layer
|
||||||
current_layer += 1
|
current_layer += 1
|
||||||
|
|
@ -219,7 +222,10 @@ while True:
|
||||||
_pressed_icons.append(NEXT_LAYER_INDEX)
|
_pressed_icons.append(NEXT_LAYER_INDEX)
|
||||||
|
|
||||||
# home layer button pressed
|
# home layer button pressed
|
||||||
if home_layer_btn.contains(p) and HOME_LAYER_INDEX not in _pressed_icons:
|
if (
|
||||||
|
home_layer_btn.contains(p)
|
||||||
|
and HOME_LAYER_INDEX not in _pressed_icons
|
||||||
|
):
|
||||||
# 0 index is home layer
|
# 0 index is home layer
|
||||||
current_layer = 0
|
current_layer = 0
|
||||||
# load the home layer
|
# load the home layer
|
||||||
|
|
@ -232,7 +238,10 @@ while True:
|
||||||
_pressed_icons.append(HOME_LAYER_INDEX)
|
_pressed_icons.append(HOME_LAYER_INDEX)
|
||||||
|
|
||||||
# Previous layer button pressed
|
# Previous layer button pressed
|
||||||
if prev_layer_btn.contains(p) and PREV_LAYER_INDEX not in _pressed_icons:
|
if (
|
||||||
|
prev_layer_btn.contains(p)
|
||||||
|
and PREV_LAYER_INDEX not in _pressed_icons
|
||||||
|
):
|
||||||
|
|
||||||
# decrement layer
|
# decrement layer
|
||||||
current_layer -= 1
|
current_layer -= 1
|
||||||
|
|
@ -258,8 +267,9 @@ while True:
|
||||||
# print("pressed {}".format(index))
|
# print("pressed {}".format(index))
|
||||||
|
|
||||||
# get actions for this icon from config object
|
# get actions for this icon from config object
|
||||||
_cur_actions = touch_deck_config["layers"][current_layer]["shortcuts"][index][
|
_cur_actions = touch_deck_config["layers"][
|
||||||
"actions"]
|
current_layer
|
||||||
|
]["shortcuts"][index]["actions"]
|
||||||
|
|
||||||
# tuple means it's a single action
|
# tuple means it's a single action
|
||||||
if isinstance(_cur_actions, tuple):
|
if isinstance(_cur_actions, tuple):
|
||||||
|
|
@ -302,4 +312,4 @@ while True:
|
||||||
else: # screen not touched
|
else: # screen not touched
|
||||||
|
|
||||||
# empty the pressed icons list
|
# empty the pressed icons list
|
||||||
_pressed_icons.clear()
|
_pressed_icons.clear()
|
||||||
|
|
|
||||||
|
|
@ -8,71 +8,71 @@ KEY_PRESS = 4
|
||||||
KEY_RELEASE = 5
|
KEY_RELEASE = 5
|
||||||
|
|
||||||
touch_deck_config = {
|
touch_deck_config = {
|
||||||
"layers":[
|
"layers": [
|
||||||
{
|
{
|
||||||
"name": "Youtube Controls",
|
"name": "Youtube Controls",
|
||||||
"shortcuts": [
|
"shortcuts": [
|
||||||
{
|
{
|
||||||
"label": "Play",
|
"label": "Play",
|
||||||
"icon": "touch_deck_icons/pr_play.bmp",
|
"icon": "touch_deck_icons/pr_play.bmp",
|
||||||
"actions": (KEY, [Keycode.K])
|
"actions": (KEY, [Keycode.K]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Pause",
|
"label": "Pause",
|
||||||
"icon": "touch_deck_icons/pr_pause.bmp",
|
"icon": "touch_deck_icons/pr_pause.bmp",
|
||||||
"actions": (KEY, [Keycode.K])
|
"actions": (KEY, [Keycode.K]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Rewind",
|
"label": "Rewind",
|
||||||
"icon": "touch_deck_icons/pr_rewind.bmp",
|
"icon": "touch_deck_icons/pr_rewind.bmp",
|
||||||
"actions": (KEY, [Keycode.LEFT_ARROW])
|
"actions": (KEY, [Keycode.LEFT_ARROW]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "FastForward",
|
"label": "FastForward",
|
||||||
"icon": "touch_deck_icons/pr_ffwd.bmp",
|
"icon": "touch_deck_icons/pr_ffwd.bmp",
|
||||||
"actions": (KEY, [Keycode.RIGHT_ARROW])
|
"actions": (KEY, [Keycode.RIGHT_ARROW]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Previous",
|
"label": "Previous",
|
||||||
"icon": "touch_deck_icons/pr_previous.bmp",
|
"icon": "touch_deck_icons/pr_previous.bmp",
|
||||||
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.P])
|
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.P]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Next",
|
"label": "Next",
|
||||||
"icon": "touch_deck_icons/pr_next.bmp",
|
"icon": "touch_deck_icons/pr_next.bmp",
|
||||||
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.N])
|
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.N]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Vol -",
|
"label": "Vol -",
|
||||||
"icon": "touch_deck_icons/pr_voldown.bmp",
|
"icon": "touch_deck_icons/pr_voldown.bmp",
|
||||||
"actions": (MEDIA, ConsumerControlCode.VOLUME_DECREMENT)
|
"actions": (MEDIA, ConsumerControlCode.VOLUME_DECREMENT),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Vol +",
|
"label": "Vol +",
|
||||||
"icon": "touch_deck_icons/pr_volup.bmp",
|
"icon": "touch_deck_icons/pr_volup.bmp",
|
||||||
"actions": (MEDIA, ConsumerControlCode.VOLUME_INCREMENT)
|
"actions": (MEDIA, ConsumerControlCode.VOLUME_INCREMENT),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Fullscreen",
|
"label": "Fullscreen",
|
||||||
"icon": "touch_deck_icons/pr_fullscreen.bmp",
|
"icon": "touch_deck_icons/pr_fullscreen.bmp",
|
||||||
"actions": (KEY, [Keycode.F])
|
"actions": (KEY, [Keycode.F]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Slow",
|
"label": "Slow",
|
||||||
"icon": "touch_deck_icons/pr_slow.bmp",
|
"icon": "touch_deck_icons/pr_slow.bmp",
|
||||||
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.COMMA])
|
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.COMMA]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Fast",
|
"label": "Fast",
|
||||||
"icon": "touch_deck_icons/pr_fast.bmp",
|
"icon": "touch_deck_icons/pr_fast.bmp",
|
||||||
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.PERIOD])
|
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.PERIOD]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Mute",
|
"label": "Mute",
|
||||||
"icon": "touch_deck_icons/pr_mute.bmp",
|
"icon": "touch_deck_icons/pr_mute.bmp",
|
||||||
"actions": (KEY, [Keycode.M])
|
"actions": (KEY, [Keycode.M]),
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Discord",
|
"name": "Discord",
|
||||||
|
|
@ -80,104 +80,129 @@ touch_deck_config = {
|
||||||
{
|
{
|
||||||
"label": "Blinka",
|
"label": "Blinka",
|
||||||
"icon": "touch_deck_icons/af_blinka.bmp",
|
"icon": "touch_deck_icons/af_blinka.bmp",
|
||||||
"actions": (STRING, ":blinka:")
|
"actions": (STRING, ":blinka:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Adabot",
|
"label": "Adabot",
|
||||||
"icon": "touch_deck_icons/af_adabot.bmp",
|
"icon": "touch_deck_icons/af_adabot.bmp",
|
||||||
"actions": (STRING, ":adabot:")
|
"actions": (STRING, ":adabot:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Billie",
|
"label": "Billie",
|
||||||
"icon": "touch_deck_icons/af_billie.bmp",
|
"icon": "touch_deck_icons/af_billie.bmp",
|
||||||
"actions": (STRING, ":billie:")
|
"actions": (STRING, ":billie:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Cappy",
|
"label": "Cappy",
|
||||||
"icon": "touch_deck_icons/af_cappy.bmp",
|
"icon": "touch_deck_icons/af_cappy.bmp",
|
||||||
"actions": (STRING, ":cappy:")
|
"actions": (STRING, ":cappy:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Connie",
|
"label": "Connie",
|
||||||
"icon": "touch_deck_icons/af_connie.bmp",
|
"icon": "touch_deck_icons/af_connie.bmp",
|
||||||
"actions": (STRING, ":connie:")
|
"actions": (STRING, ":connie:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Gus",
|
"label": "Gus",
|
||||||
"icon": "touch_deck_icons/af_gus.bmp",
|
"icon": "touch_deck_icons/af_gus.bmp",
|
||||||
"actions": (STRING, ":gus:")
|
"actions": (STRING, ":gus:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Hans",
|
"label": "Hans",
|
||||||
"icon": "touch_deck_icons/af_hans.bmp",
|
"icon": "touch_deck_icons/af_hans.bmp",
|
||||||
"actions": (STRING, ":hans:")
|
"actions": (STRING, ":hans:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Mho",
|
"label": "Mho",
|
||||||
"icon": "touch_deck_icons/af_mho.bmp",
|
"icon": "touch_deck_icons/af_mho.bmp",
|
||||||
"actions": (STRING, ":mho:")
|
"actions": (STRING, ":mho:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Minerva",
|
"label": "Minerva",
|
||||||
"icon": "touch_deck_icons/af_minerva.bmp",
|
"icon": "touch_deck_icons/af_minerva.bmp",
|
||||||
"actions": (STRING, ":minerva:")
|
"actions": (STRING, ":minerva:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "NeoTrellis",
|
"label": "NeoTrellis",
|
||||||
"icon": "touch_deck_icons/af_neotrellis.bmp",
|
"icon": "touch_deck_icons/af_neotrellis.bmp",
|
||||||
"actions": (STRING, ":neotrellis:")
|
"actions": (STRING, ":neotrellis:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Ruby",
|
"label": "Ruby",
|
||||||
"icon": "touch_deck_icons/af_ruby.bmp",
|
"icon": "touch_deck_icons/af_ruby.bmp",
|
||||||
"actions": (STRING, ":ruby:")
|
"actions": (STRING, ":ruby:"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Sparky",
|
"label": "Sparky",
|
||||||
"icon": "touch_deck_icons/af_sparky.bmp",
|
"icon": "touch_deck_icons/af_sparky.bmp",
|
||||||
"actions": (STRING, ":sparky:")
|
"actions": (STRING, ":sparky:"),
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Test Third Layer",
|
"name": "Symbols",
|
||||||
"shortcuts": [
|
"shortcuts": [
|
||||||
{
|
{
|
||||||
"label": "Flameshot",
|
"label": "Infinity", # ∞
|
||||||
"icon": "touch_deck_icons/test48_icon.bmp",
|
"icon": "touch_deck_icons/sy_infinity.bmp",
|
||||||
# \n can be used in the string for enter key
|
"actions": (KEY, [Keycode.ALT, Keycode.FIVE]),
|
||||||
"actions": [(KEY, [Keycode.GUI]), (STRING, "flameshot\n")]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Calculator",
|
"label": "Degree", # º
|
||||||
"icon": "touch_deck_icons/test48_icon.bmp",
|
"icon": "touch_deck_icons/sy_degree.bmp",
|
||||||
"actions": [(KEY, [Keycode.GUI, Keycode.SPACE]), (STRING, "Calculator")]
|
"actions": (KEY, [Keycode.ALT, Keycode.ZERO]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Test (D)",
|
"label": "Pi", # π
|
||||||
"icon": "touch_deck_icons/test48_icon.bmp",
|
"icon": "touch_deck_icons/sy_pi.bmp",
|
||||||
"actions": [(KEY, [Keycode.CONTROL, Keycode.SHIFT, Keycode.U]), (STRING, "221e\n")]
|
"actions": (KEY, [Keycode.ALT, Keycode.P]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Test (L)",
|
"label": "Sigma", # ∑
|
||||||
"icon": "touch_deck_icons/test48_icon.bmp",
|
"icon": "touch_deck_icons/sy_sigma.bmp",
|
||||||
"actions": [
|
"actions": (KEY, [Keycode.ALT, Keycode.W]),
|
||||||
(KEY_PRESS, [Keycode.SHIFT]),
|
|
||||||
(KEY, [Keycode.B]),
|
|
||||||
(KEY, [Keycode.L]),
|
|
||||||
(KEY, [Keycode.I]),
|
|
||||||
(KEY, [Keycode.N]),
|
|
||||||
(KEY, [Keycode.K]),
|
|
||||||
(KEY, [Keycode.A]),
|
|
||||||
(KEY_RELEASE, [Keycode.SHIFT])
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Test [:)]",
|
"label": "Partial diff", #
|
||||||
"icon": "touch_deck_icons/test48_icon.bmp",
|
"icon": "touch_deck_icons/sy_pdiff.bmp",
|
||||||
"actions": (KEY, [Keycode.RIGHT_SHIFT, Keycode.SEMICOLON, Keycode.ZERO])
|
"actions": (KEY, [Keycode.ALT, Keycode.D]),
|
||||||
}
|
},
|
||||||
]
|
{
|
||||||
}
|
"label": "Increment", # ∆
|
||||||
|
"icon": "touch_deck_icons/sy_increment.bmp",
|
||||||
|
"actions": (KEY, [Keycode.ALT, Keycode.J]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Omega", # Ω
|
||||||
|
"icon": "touch_deck_icons/sy_omega.bmp",
|
||||||
|
"actions": (KEY, [Keycode.ALT, Keycode.Z]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Mu", # µ
|
||||||
|
"icon": "touch_deck_icons/sy_micro.bmp",
|
||||||
|
"actions": (KEY, [Keycode.ALT, Keycode.M]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Rad O", # Ø
|
||||||
|
"icon": "touch_deck_icons/sy_rado.bmp",
|
||||||
|
"actions": (KEY, [Keycode.ALT, Keycode.SHIFT, Keycode.O]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Square root", # √
|
||||||
|
"icon": "touch_deck_icons/sy_sqrrt.bmp",
|
||||||
|
"actions": (KEY, [Keycode.ALT, Keycode.V]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Approx", # ≈
|
||||||
|
"icon": "touch_deck_icons/sy_approx.bmp",
|
||||||
|
"actions": (KEY, [Keycode.ALT, Keycode.X]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Plus minus", # ±
|
||||||
|
"icon": "touch_deck_icons/sy_plusminus.bmp",
|
||||||
|
"actions": (KEY, [Keycode.ALT, Keycode.SHIFT, Keycode.EQUALS]),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue