Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • flow3r/flow3r-firmware
  • Vespasian/flow3r-firmware
  • alxndr42/flow3r-firmware
  • pl/flow3r-firmware
  • Kari/flow3r-firmware
  • raimue/flow3r-firmware
  • grandchild/flow3r-firmware
  • mu5tach3/flow3r-firmware
  • Nervengift/flow3r-firmware
  • arachnist/flow3r-firmware
  • TheNewCivilian/flow3r-firmware
  • alibi/flow3r-firmware
  • manuel_v/flow3r-firmware
  • xeniter/flow3r-firmware
  • maxbachmann/flow3r-firmware
  • yGifoom/flow3r-firmware
  • istobic/flow3r-firmware
  • EiNSTeiN_/flow3r-firmware
  • gnudalf/flow3r-firmware
  • 999eagle/flow3r-firmware
  • toerb/flow3r-firmware
  • pandark/flow3r-firmware
  • teal/flow3r-firmware
  • x42/flow3r-firmware
  • alufers/flow3r-firmware
  • dos/flow3r-firmware
  • yrlf/flow3r-firmware
  • LuKaRo/flow3r-firmware
  • ThomasElRubio/flow3r-firmware
  • ai/flow3r-firmware
  • T_X/flow3r-firmware
  • highTower/flow3r-firmware
  • beanieboi/flow3r-firmware
  • Woazboat/flow3r-firmware
  • gooniesbro/flow3r-firmware
  • marvino/flow3r-firmware
  • kressnerd/flow3r-firmware
  • quazgar/flow3r-firmware
  • aoid/flow3r-firmware
  • jkj/flow3r-firmware
  • naomi/flow3r-firmware
41 results
Show changes
Commits on Source (5)
......@@ -123,7 +123,7 @@ void st3m_mode_update_display(bool *restartable) {
case st3m_mode_kind_disk_sd:
case st3m_mode_kind_disk_flash: {
const char *lines[] = {
"Press left shoulder button",
"Press right shoulder button",
"to exit.",
NULL,
};
......@@ -139,7 +139,7 @@ void st3m_mode_update_display(bool *restartable) {
_mode.shown = true;
const char *lines[] = {
"Send Ctrl-D over USB",
"or press left shoulder button",
"or press right shoulder button",
"to restart.",
NULL,
};
......@@ -158,7 +158,7 @@ void st3m_mode_update_display(bool *restartable) {
}
const char *lines[] = {
msg,
"Press left shoulder button",
"Press right shoulder button",
"to restart.",
NULL,
};
......@@ -186,7 +186,7 @@ static void _task(void *arg) {
st3m_mode_update_display(&restartable);
if (restartable) {
st3m_tripos tp = st3m_io_left_button_get();
st3m_tripos tp = st3m_io_right_button_get();
if (tp == st3m_tripos_mid) {
st3m_gfx_textview_t tv = {
.title = "Restarting...",
......
``sys_buttons`` module
======================
.. note::
This is a rather low-level way to access buttons, consider using `InputController` instead:
https://docs.flow3r.garden/badge/programming.html#example-1d-automatic-input-processing
.. automodule:: sys_buttons
:members:
:undoc-members:
......
......@@ -64,7 +64,7 @@ Use ``"color": "0xffffff",`` to color your name and pronouns.
Use ``"mode": "1",`` to use a different animation mode rotating your nick based on badge orientation.
When you're done editing, unmount/eject the badge from your computer
(``umount`` on Linux is enough) and press the left shoulder button to exit Disk
(``umount`` on Linux is enough) and press the right shoulder button to exit Disk
Mode. Then, go to Badge |rarr| Nick to see your changes!
If the ``nick.json`` file is unparseable or otherwise gets corrupted, it will be
......
......@@ -108,10 +108,12 @@ class AudioPassthrough(Application):
headset_connected = audio.headset_is_connected()
if self._force_mode == "FORCE_MIC":
audio.input_set_source(audio.INPUT_SOURCE_ONBOARD_MIC)
elif (
audio.line_in_is_connected() and self._force_mode == "AUTO"
) or self._force_mode == "FORCE_LINE_IN":
audio.input_set_source(audio.INPUT_SOURCE_LINE_IN)
elif headset_connected or self._force_mode == "FORCE_LINE_OUT":
audio.input_set_source(audio.INPUT_SOURCE_HEADSET_MIC)
elif audio.line_in_is_connected() or self._force_mode == "FORCE_LINE_IN":
audio.input_set_source(audio.INPUT_SOURCE_LINE_IN)
else:
audio.input_set_source(audio.INPUT_SOURCE_NONE)
......
......@@ -10,4 +10,4 @@ author = "ave"
license = "LGPL-3.0-only"
url = "https://git.flow3r.garden/flow3r/flow3r-firmware"
description = "Allows toggling audio passthrough through line-in/mic to speaker or lineout."
version = 6
version = 7
import bl00mbox
import captouch
import leds
import captouch
from st3m.application import Application, ApplicationContext
from st3m.input import InputState
......@@ -36,7 +36,7 @@ class GayDrums(Application):
self.seq.signals.bpm.value = 80
self.track_names = ["kick", "hihat", "snare", "crash", "nya", "woof"]
self.ct_prev = captouch.read()
self.ct_prev: Optional[captouch.CaptouchState] = None
self.track = 1
self.blm.background_mute_override = True
self.tap_tempo_press_counter = 0
......@@ -59,7 +59,12 @@ class GayDrums(Application):
self._redraw_background = 2
self._group_gap = 5
self.background_col: Color = (0, 0, 0)
self.highlight_col: Color = (0.15, 0.15, 0.15)
self.bar_col = (0.5, 0.5, 0.5)
self.highlight_col: Color = self.bar_col
self.highlight_outline: bool = True
self.draw_background_counter = 0
self.full_redraw_timer_ms = 0
def set_bar_mode(self, mode: int) -> None:
# TODO: figure out how to speed up re-render
......@@ -128,23 +133,17 @@ class GayDrums(Application):
def draw_background(self, ctx: Context, data: None) -> None:
ctx.rgb(0, 0, 0).rectangle(-120, -120, 240, 240).fill()
# group bars
bar_len = 10 * (1 + self.num_samplers)
bar_pos = 4 * 12 + self._group_gap
self.ctx_draw_centered_rect(ctx, 0, 0, 1, bar_len, (0.5, 0.5, 0.5))
self.ctx_draw_centered_rect(ctx, bar_pos, 0, 1, bar_len, (0.5, 0.5, 0.5))
self.ctx_draw_centered_rect(ctx, -bar_pos, 0, 1, bar_len, (0.5, 0.5, 0.5))
self.draw_bars(ctx, None)
ctx.font = ctx.get_font_name(1)
ctx.font_size = 15
ctx.rgb(0.6, 0.6, 0.6)
ctx.move_to(0, -85)
ctx.move_to(0, -80)
ctx.text("(hold) stop")
ctx.move_to(0, -100)
ctx.move_to(0, -95)
ctx.text("tap tempo")
self.draw_track_name(ctx, None)
......@@ -212,7 +211,6 @@ class GayDrums(Application):
def draw_track_step_marker(self, ctx: Context, data: Tuple[int, int]) -> None:
track, step = data
self._group_gap = 4
rgb = self._track_col(track)
rgbf = (rgb[0] / 256, rgb[1] / 256, rgb[2] / 256)
y = -int(12 * (track - (self.num_samplers - 1) / 2))
......@@ -223,7 +221,7 @@ class GayDrums(Application):
x = int(-x)
group = step // 4
bg = self.background_col
if self._group_highlight_on[group]:
if self._group_highlight_on[group] and not self.highlight_outline:
bg = self.highlight_col
if trigger_state == 3:
self.ctx_draw_centered_rect(ctx, x, y, 8, 8, rgbf)
......@@ -245,58 +243,116 @@ class GayDrums(Application):
nosy = int(posy - (sizey / 2))
ctx.rectangle(nosx, nosy, int(sizex), int(sizey)).fill()
def draw_bars(self, ctx: Context, data: None) -> None:
ctx.move_to(0, 0)
bar_len = 10 * (1 + self.num_samplers)
bar_pos = 4 * 12 + self._group_gap
self.ctx_draw_centered_rect(ctx, 0, 0, 1, bar_len, self.bar_col)
self.ctx_draw_centered_rect(ctx, bar_pos, 0, 1, bar_len, self.bar_col)
self.ctx_draw_centered_rect(ctx, -bar_pos, 0, 1, bar_len, self.bar_col)
def draw_group_highlight(self, ctx: Context, data: int) -> None:
i = data
col = self.background_col
if self._group_highlight_on[i]:
col = self.highlight_col
sizex = 48 + self._group_gap - 2
sizey = 10 * (1 + self.num_samplers)
posx = -int((12 * 4 + 1 + self._group_gap) * (1.5 - i))
bar_len = 10 * (1 + self.num_samplers)
bar_pos = 4 * 12 + self._group_gap
sizex = 4 * 12
sizey = bar_len
posx = int(bar_pos * (i - 1.5))
posy = 0
self.ctx_draw_centered_rect(ctx, posx, posy, sizex, sizey, col)
for x in range(self.num_samplers):
for y in range(4):
self.draw_track_step_marker(ctx, (x, y + 4 * i))
if self.highlight_outline:
self.ctx_draw_centered_rect(
ctx, posx, int(sizey / 2) + 2, sizex - 2, 1, col
)
self.ctx_draw_centered_rect(
ctx, posx, int(-sizey / 2) - 2, sizex - 2, 1, col
)
if i == 0:
self.ctx_draw_centered_rect(ctx, -2 * bar_pos, 0, 1, bar_len, col)
if i == 3:
self.ctx_draw_centered_rect(ctx, 2 * bar_pos, 0, 1, bar_len, col)
else:
self.ctx_draw_centered_rect(ctx, posx, posy, sizex, sizey, col)
for x in range(self.num_samplers):
for y in range(4):
self.draw_track_step_marker(ctx, (x, y + 4 * i))
def draw_bpm(self, ctx: Context, data: None) -> None:
self.ctx_draw_centered_rect(ctx, 0, -65, 200, 22, (0, 0, 0))
ctx.text_align = ctx.MIDDLE
ctx.move_to(0, 0)
self.ctx_draw_centered_rect(ctx, 0, -60, 200, 24, (0, 0, 0))
bpm = self.seq.signals.bpm.value
ctx.font = ctx.get_font_name(1)
ctx.font_size = 20
ctx.move_to(0, -65)
ctx.move_to(0, -60)
ctx.rgb(255, 255, 255)
ctx.text(str(bpm) + " bpm")
def draw_volume_area(self, ctx: Context, data: None) -> None:
ctx.move_to(0, 0)
bar_len = 10 * (1 + self.num_samplers)
self.ctx_draw_centered_rect(ctx, 0, 0, 6 * 12, bar_len, (0, 0, 0))
self.ctx_draw_centered_rect(ctx, 0, 0, 1, bar_len, (0.5, 0.5, 0.5))
for track in range(self.num_samplers):
for step in range(5, 16 - 5):
self.draw_track_step_marker(ctx, (track, step))
for i in range(1, 3):
self._group_highlight_redraw[i] = True
def draw(self, ctx: Context) -> None:
ctx.text_align = ctx.MIDDLE
if not self.init_complete:
ctx.rgb(0, 0, 0).rectangle(-120, -120, 240, 240).fill()
ctx.font = ctx.get_font_name(0)
ctx.text_align = ctx.MIDDLE
ctx.font_size = 24
ctx.move_to(0, -10)
ctx.move_to(0, -40)
ctx.rgb(0.8, 0.8, 0.8)
if self.samples_loaded == self.samples_total:
ctx.text("Loading complete")
self.loading_text = "(drawing screen will take a sec)"
else:
ctx.text("Loading samples...")
ctx.font_size = 16
ctx.move_to(0, 10)
ctx.move_to(0, -20)
ctx.text(self.loading_text)
tutorial = (
"how to:\n"
"press one of the 4 left petals\n"
"and one of the 4 right petals\n"
"at the same time to toggle\n"
"an event in the grid"
)
ctx.font_size = 16
for x, line in enumerate(tutorial.split("\n")):
if not x:
continue
ctx.move_to(0, 5 + 19 * x)
ctx.text(line)
progress = self.samples_loaded / self.samples_total
bar_len = 120 / self.samples_total
for x in range(self.samples_loaded):
rgb = self._track_col(x)
rgbf = (rgb[0] / 256, rgb[1] / 256, rgb[2] / 256)
ctx.rgb(*rgbf)
ctx.rectangle(x * bar_len - 60, 30, bar_len, 10).fill()
ctx.rectangle(x * bar_len - 60, -8, bar_len, 10).fill()
return
if self.draw_background_counter > 0:
self._render_list_1 += [(self.draw_background, None)]
self._render_list_1 += [(self.draw_background, None)]
self.draw_background_counter -= 1
for i in range(4):
if self._group_highlight_redraw[i]:
self._group_highlight_redraw[i] = False
......@@ -327,7 +383,7 @@ class GayDrums(Application):
self.ctx_draw_centered_rect(ctx, stepx, stepy, dotsize, dotsize, (1, 1, 1))
def draw_track_name(self, ctx: Context, data: None) -> None:
self.ctx_draw_centered_rect(ctx, 0, 60, 200, 30, self.background_col)
self.ctx_draw_centered_rect(ctx, 0, 60, 200, 40, self.background_col)
ctx.font = ctx.get_font_name(1)
ctx.text_align = ctx.MIDDLE
......@@ -370,6 +426,18 @@ class GayDrums(Application):
def think(self, ins: InputState, delta_ms: int) -> None:
super().think(ins, delta_ms)
if self.full_redraw_timer_ms > 0:
self.full_redraw_timer_ms -= delta_ms
if self.full_redraw_timer_ms < 0:
self._render_list_1 += [(self.draw_volume_area, None)]
if self.input.buttons.os.left.pressed or self.input.buttons.os.right.pressed:
self.full_redraw_timer_ms = 2000
if self.ct_prev is None:
self.ct_prev = ins.captouch
return
if not self.init_complete:
try:
self.samples_loaded, self.loading_text = next(self.load_iter)
......@@ -389,7 +457,7 @@ class GayDrums(Application):
self.bar = st // 16
self._group_highlight_redraw = [True] * 4
ct = captouch.read()
ct = ins.captouch
for i in range(4):
if ct.petals[6 + i].pressed:
if not self._group_highlight_on[i]:
......@@ -456,5 +524,5 @@ class GayDrums(Application):
self.ct_prev = ct
def on_enter(self, vm: Optional[ViewManager]) -> None:
self._render_list_1 += [(self.draw_background, None)]
self._render_list_1 += [(self.draw_background, None)] # nice
self.ct_prev = None
self.draw_background_counter = 2