Skip to content

Commit

Permalink
Rework Karma output
Browse files Browse the repository at this point in the history
  • Loading branch information
atulrnt committed May 31, 2024
1 parent 6d31130 commit cdc827f
Showing 1 changed file with 37 additions and 204 deletions.
241 changes: 37 additions & 204 deletions software/contrib/karma.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from europi import *
from time import ticks_diff, ticks_ms
from random import randint, choice
from europi_script import EuroPiScript
from experimental.knobs import LockableKnob, KnobBank
import framebuf
from experimental.knobs import LockableKnob
from random import randint
from time import ticks_diff, ticks_ms


# Extend EuroPiScript to allow for each output to manage its own state, the main class is Karma
Expand Down Expand Up @@ -271,152 +270,13 @@ class KarmaDisplay:
by closing the menu after some time allows for the script to goes back to a faster run time.
Pixels can also burn if they stay active for an extended period of time.
"""
MENU_DELAY = 10000
MENU_DELAY = 1000 * 10

DIRECTION_LEFT = 0
DIRECTION_RIGHT = 1
DIRECTION_TOP = 2
DIRECTION_BOTTOM = 3

SCREENSAVERS = [
[
0x00, 0x04, 0x3b, 0x81, 0x40, 0x23, 0x80, 0x22, 0x22, 0x03, 0x82, 0x01, 0xa0, 0x8e, 0x18, 0x00,
0x00, 0x04, 0x6e, 0x81, 0x20, 0x20, 0xf0, 0x23, 0x62, 0x0e, 0x81, 0x01, 0x20, 0x03, 0xb0, 0x00,
0x00, 0x07, 0xb8, 0x81, 0x20, 0x40, 0x98, 0x21, 0x42, 0x19, 0x01, 0x82, 0x20, 0x40, 0xf0, 0x00,
0x00, 0x07, 0xe0, 0x01, 0x10, 0xc0, 0x46, 0x21, 0xc2, 0x61, 0x00, 0x86, 0x20, 0x40, 0x70, 0x00,
0x00, 0x0f, 0x81, 0x01, 0x00, 0x80, 0x41, 0xa0, 0x82, 0xc3, 0x00, 0x44, 0x20, 0x40, 0x7c, 0x00,
0x00, 0x3b, 0x01, 0x01, 0x09, 0x00, 0x20, 0xe0, 0x83, 0x02, 0x00, 0x48, 0x20, 0x20, 0xce, 0x00,
0x00, 0xc9, 0x81, 0x01, 0x07, 0x00, 0x10, 0x31, 0xc6, 0x04, 0x00, 0x38, 0x20, 0x20, 0xc3, 0xc0,
0x03, 0x18, 0xc2, 0x01, 0x02, 0x00, 0x18, 0x19, 0x4c, 0x0c, 0x00, 0x30, 0x20, 0x21, 0x81, 0xe0,
0x0c, 0x30, 0xc2, 0x01, 0x07, 0x00, 0x08, 0x1d, 0x48, 0x08, 0x00, 0x70, 0x20, 0x23, 0x00, 0x98,
0x98, 0x60, 0x62, 0x01, 0x04, 0xc0, 0x04, 0x17, 0x74, 0x1f, 0xff, 0xc8, 0x20, 0x17, 0x00, 0x46,
0xe0, 0xc0, 0x32, 0x01, 0x08, 0x7f, 0xff, 0x13, 0x24, 0xfc, 0x03, 0xf8, 0x20, 0x16, 0x00, 0x21,
0x80, 0x80, 0x12, 0x01, 0x0b, 0xf0, 0x03, 0xf3, 0x67, 0xe0, 0x06, 0x0e, 0x20, 0x18, 0x00, 0x10,
0x01, 0x00, 0x0e, 0x01, 0x1c, 0x0c, 0x01, 0x9e, 0xfc, 0xc0, 0x0c, 0x07, 0xa0, 0x14, 0x00, 0x18,
0x02, 0x00, 0x0e, 0x01, 0x70, 0x06, 0x00, 0xcf, 0xf9, 0x80, 0x30, 0x02, 0x60, 0x78, 0x00, 0x09,
0x44, 0x00, 0x06, 0x01, 0xa0, 0x01, 0x80, 0x6f, 0xff, 0x00, 0x60, 0x02, 0x38, 0x58, 0x00, 0x07,
0x44, 0x00, 0x07, 0x07, 0x20, 0x00, 0xe0, 0xff, 0x3f, 0xe1, 0xc0, 0x01, 0x26, 0x90, 0x00, 0x06,
0x28, 0x00, 0x06, 0xd9, 0x40, 0x00, 0x1e, 0x0e, 0x3c, 0x1f, 0x00, 0x01, 0xa7, 0xb0, 0x00, 0x06,
0x30, 0x00, 0x06, 0x71, 0x20, 0x00, 0x73, 0xf7, 0x3f, 0xe1, 0xc0, 0x01, 0x2c, 0xd0, 0x00, 0x05,
0x10, 0x00, 0x06, 0x59, 0x20, 0x01, 0xc0, 0x3f, 0xff, 0x00, 0x60, 0x03, 0x30, 0x78, 0x00, 0x09,
0x38, 0x00, 0x0e, 0x8f, 0x10, 0x03, 0x00, 0x4f, 0xf8, 0x80, 0x18, 0x02, 0xe0, 0x38, 0x00, 0x00,
0x28, 0x00, 0x0b, 0x03, 0x90, 0x06, 0x00, 0x8e, 0xfc, 0x40, 0x0c, 0x07, 0x20, 0x1c, 0x00, 0x10,
0x84, 0x00, 0x12, 0x01, 0xf8, 0x18, 0x01, 0x39, 0xe7, 0xa0, 0x03, 0x1c, 0x20, 0x1c, 0x00, 0x20,
0x46, 0x00, 0x16, 0x01, 0x1e, 0x30, 0x03, 0xf1, 0x20, 0xfc, 0x07, 0xe8, 0x20, 0x16, 0x00, 0x41,
0x72, 0x00, 0x2e, 0x01, 0x0f, 0xff, 0xfe, 0x13, 0x32, 0x0f, 0xfc, 0xc8, 0x20, 0x13, 0x00, 0x86,
0x4d, 0x00, 0x7a, 0x01, 0x04, 0x87, 0x04, 0x17, 0x3a, 0x0c, 0x00, 0x38, 0x20, 0x31, 0x01, 0x8c,
0x03, 0x80, 0x52, 0x01, 0x03, 0x00, 0x08, 0x1d, 0x2e, 0x06, 0x00, 0x10, 0x20, 0x21, 0x83, 0x30,
0x81, 0xc0, 0xe1, 0x01, 0x03, 0x00, 0x18, 0x18, 0xc2, 0x02, 0x00, 0x38, 0x20, 0x20, 0x86, 0xc0,
0x80, 0x31, 0xc1, 0x01, 0x05, 0x00, 0x30, 0x20, 0xc1, 0x01, 0x00, 0x64, 0x20, 0x20, 0x4f, 0x00,
0x80, 0x09, 0xc1, 0x01, 0x08, 0x80, 0x20, 0x60, 0xc1, 0xc1, 0x80, 0x46, 0x20, 0x40, 0x3c, 0x00,
0x80, 0x06, 0x81, 0x01, 0x08, 0x80, 0x41, 0xa0, 0xc1, 0x60, 0x80, 0x82, 0x20, 0x40, 0x70, 0x00,
0x80, 0x03, 0x80, 0x01, 0x10, 0x40, 0x43, 0x20, 0xc1, 0x18, 0x40, 0x81, 0x20, 0x41, 0xf0, 0x00,
0x80, 0x05, 0xe0, 0x81, 0x30, 0x60, 0xcc, 0x21, 0xa1, 0x06, 0x41, 0x01, 0xa0, 0x07, 0x90, 0x00
],
[
0x32, 0x00, 0x36, 0x08, 0xe0, 0x08, 0xc6, 0x00, 0x80, 0x21, 0x08, 0x01, 0xc8, 0x66, 0x00, 0x4e,
0x32, 0x00, 0x62, 0x0f, 0x00, 0x0b, 0x86, 0x01, 0xc0, 0x30, 0xc8, 0x00, 0x78, 0x63, 0x00, 0xce,
0x33, 0x00, 0xc3, 0x1e, 0x00, 0x0f, 0x04, 0x03, 0x60, 0x10, 0x78, 0x00, 0x3c, 0x41, 0x00, 0xce,
0x31, 0x00, 0x83, 0x34, 0x00, 0x38, 0x0c, 0x06, 0x30, 0x10, 0x1c, 0x00, 0x26, 0xc0, 0x80, 0x86,
0x60, 0x03, 0x01, 0xc2, 0x01, 0x88, 0x18, 0x08, 0x08, 0x1c, 0x09, 0xc0, 0x61, 0x80, 0x60, 0x06,
0x60, 0x86, 0x00, 0x83, 0x07, 0x08, 0xff, 0xf0, 0x0f, 0xff, 0x08, 0x70, 0x40, 0x80, 0x31, 0x03,
0x60, 0x8c, 0x01, 0x83, 0x02, 0x09, 0xcc, 0x00, 0x00, 0x11, 0x88, 0x20, 0xc0, 0xc0, 0x11, 0x03,
0xe0, 0x88, 0x03, 0x81, 0x03, 0x0f, 0x0c, 0x00, 0x00, 0x10, 0xf8, 0x60, 0x81, 0x60, 0x09, 0x03,
0xa0, 0x70, 0x0c, 0xc0, 0x01, 0x18, 0x0c, 0x00, 0x00, 0x10, 0x0c, 0x40, 0x03, 0x10, 0x06, 0x07,
0x20, 0x60, 0x08, 0x40, 0x81, 0x38, 0x0c, 0x00, 0x00, 0x10, 0x0e, 0xc0, 0x02, 0x08, 0x07, 0x02,
0x20, 0xe0, 0x10, 0x60, 0x80, 0xcc, 0x0c, 0x00, 0x00, 0x10, 0x13, 0x81, 0x02, 0x0c, 0x07, 0x06,
0x20, 0xb0, 0x30, 0x20, 0xc0, 0x84, 0x0c, 0x00, 0x00, 0x10, 0x13, 0x81, 0x06, 0x06, 0x04, 0x86,
0x23, 0x10, 0xc0, 0x10, 0x43, 0x86, 0x08, 0x00, 0x00, 0x08, 0x31, 0x82, 0x0c, 0x01, 0x08, 0x66,
0x26, 0x10, 0x80, 0x10, 0x66, 0xc2, 0x10, 0x00, 0x00, 0x0c, 0x21, 0xc2, 0x08, 0x00, 0x88, 0x36,
0x2c, 0x01, 0x00, 0x10, 0x2c, 0x43, 0x30, 0x00, 0x00, 0x06, 0x61, 0x66, 0x08, 0x00, 0xc0, 0x16,
0x38, 0x0b, 0x00, 0x00, 0x38, 0x61, 0x60, 0x00, 0x00, 0x03, 0x43, 0x34, 0x08, 0x00, 0x70, 0x0e,
0x30, 0x0e, 0x00, 0x08, 0x18, 0x21, 0xc0, 0x00, 0x00, 0x01, 0xc2, 0x0c, 0x00, 0x00, 0x30, 0x0e,
0x30, 0x0f, 0x00, 0x08, 0x1c, 0x61, 0x60, 0x00, 0x00, 0x03, 0xc3, 0x0c, 0x08, 0x00, 0x70, 0x0e,
0x28, 0x09, 0x00, 0x00, 0x36, 0x43, 0x30, 0x00, 0x00, 0x06, 0x43, 0x16, 0x08, 0x00, 0xc8, 0x1e,
0x2c, 0x08, 0x80, 0x00, 0x23, 0xc2, 0x30, 0x00, 0x00, 0x0c, 0x61, 0x32, 0x0c, 0x00, 0x88, 0x32,
0x26, 0x00, 0xc0, 0x10, 0x61, 0x86, 0x18, 0x00, 0x00, 0x08, 0x21, 0x63, 0x04, 0x01, 0x0c, 0x66,
0x21, 0x10, 0x30, 0x30, 0x40, 0xc4, 0x0c, 0x00, 0x00, 0x10, 0x10, 0x81, 0x06, 0x06, 0x06, 0x86,
0x20, 0xb0, 0x10, 0x20, 0xc0, 0xec, 0x0c, 0x00, 0x00, 0x10, 0x11, 0x80, 0x02, 0x0c, 0x03, 0x06,
0x20, 0xe0, 0x08, 0x60, 0x81, 0x38, 0x0c, 0x00, 0x00, 0x10, 0x13, 0x80, 0x03, 0x08, 0x03, 0x02,
0xa0, 0x60, 0x0c, 0x60, 0x81, 0x18, 0x0c, 0x00, 0x00, 0x10, 0x0e, 0xc0, 0x81, 0x10, 0x07, 0x02,
0xe0, 0x70, 0x03, 0xc0, 0x03, 0x0f, 0x0c, 0x00, 0x00, 0x10, 0x78, 0x60, 0xc0, 0x60, 0x09, 0x03,
0x60, 0xc8, 0x01, 0x81, 0x02, 0x03, 0x8c, 0x00, 0x00, 0x10, 0xc8, 0x60, 0x40, 0xc0, 0x10, 0x03,
0x60, 0xcc, 0x00, 0x81, 0x07, 0x00, 0xff, 0xf0, 0x0f, 0xf7, 0x08, 0x60, 0x60, 0x80, 0x30, 0x83,
0x60, 0x86, 0x00, 0xc3, 0x03, 0x80, 0x1f, 0xf8, 0x0f, 0xfe, 0x08, 0xe0, 0x61, 0x80, 0x60, 0x82,
0x30, 0x01, 0x01, 0x32, 0x00, 0x38, 0x0c, 0x06, 0x30, 0x10, 0x0e, 0x00, 0x36, 0x40, 0x80, 0xc6,
0x31, 0x00, 0x81, 0x16, 0x00, 0x1e, 0x0c, 0x03, 0x60, 0x10, 0x38, 0x00, 0x3c, 0x61, 0x00, 0x46,
0x31, 0x00, 0xe3, 0x0e, 0x00, 0x03, 0x04, 0x01, 0xc0, 0x30, 0xf8, 0x00, 0xf8, 0x63, 0x00, 0x6e
],
[
0x40, 0x04, 0x1c, 0x00, 0x98, 0x02, 0x03, 0x00, 0x80, 0x20, 0x21, 0xdf, 0x80, 0x0c, 0x18, 0x01,
0x40, 0x04, 0x30, 0x01, 0x0e, 0x02, 0x01, 0x00, 0x80, 0x40, 0x20, 0x36, 0x00, 0x07, 0x10, 0x01,
0x20, 0x02, 0xc0, 0x01, 0x0d, 0x84, 0x01, 0x80, 0x80, 0xc0, 0x10, 0xcc, 0x40, 0x01, 0xa0, 0x02,
0x20, 0x03, 0x00, 0x02, 0x04, 0xe4, 0x00, 0x80, 0x80, 0x80, 0x11, 0x88, 0x40, 0x00, 0x60, 0x02,
0x10, 0x0f, 0x00, 0x06, 0x02, 0x38, 0x00, 0x40, 0x81, 0x00, 0x0e, 0x10, 0x20, 0x00, 0x70, 0x04,
0x10, 0x19, 0x80, 0x04, 0x03, 0x1c, 0x00, 0x40, 0x81, 0x00, 0x0c, 0x30, 0x30, 0x00, 0xcc, 0x04,
0x08, 0x60, 0xc0, 0x08, 0x01, 0x13, 0x00, 0x20, 0x82, 0x00, 0x64, 0x60, 0x18, 0x00, 0x83, 0x08,
0x05, 0x80, 0x40, 0x18, 0x01, 0xa0, 0xc0, 0x10, 0x84, 0x01, 0x82, 0x40, 0x08, 0x01, 0x00, 0xd0,
0x06, 0x00, 0x60, 0x10, 0x00, 0xa0, 0x70, 0x10, 0x84, 0x07, 0x03, 0x40, 0x0c, 0x03, 0x00, 0x30,
0x1d, 0x00, 0x20, 0x20, 0x00, 0xc0, 0x18, 0x08, 0x88, 0x0c, 0x01, 0x80, 0x04, 0x02, 0x00, 0x7c,
0x30, 0x80, 0x10, 0x20, 0x01, 0x80, 0x06, 0x0c, 0x98, 0x30, 0x00, 0xc0, 0x02, 0x04, 0x00, 0xc6,
0xc0, 0x40, 0x10, 0x40, 0x03, 0x40, 0x03, 0x04, 0x90, 0x60, 0x00, 0xe0, 0x03, 0x04, 0x01, 0x01,
0x00, 0x20, 0x08, 0xc0, 0x06, 0x40, 0x00, 0xc2, 0xb1, 0x80, 0x01, 0xb0, 0x01, 0x08, 0x02, 0x00,
0x00, 0x18, 0x0c, 0x80, 0x18, 0x40, 0x00, 0x32, 0xa6, 0x00, 0x01, 0x0c, 0x00, 0x88, 0x0c, 0x00,
0x00, 0x0e, 0x05, 0x00, 0x70, 0x40, 0x00, 0x1d, 0xcc, 0x00, 0x01, 0x03, 0x00, 0x90, 0x38, 0x00,
0x00, 0x01, 0xc7, 0x01, 0x80, 0x40, 0x00, 0x07, 0xf0, 0x00, 0x01, 0x00, 0xc0, 0x51, 0xc0, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
0x00, 0x03, 0x83, 0x01, 0x80, 0x40, 0x00, 0x03, 0xe0, 0x00, 0x01, 0x00, 0xe0, 0x60, 0x70, 0x00,
0x00, 0x0c, 0x05, 0x00, 0x60, 0x40, 0x00, 0x0f, 0xf8, 0x00, 0x01, 0x03, 0x80, 0xd0, 0x1c, 0x00,
0x00, 0x10, 0x05, 0x80, 0x18, 0x40, 0x00, 0x1b, 0xee, 0x00, 0x01, 0x06, 0x00, 0x90, 0x06, 0x00,
0x00, 0x60, 0x08, 0x80, 0x04, 0x40, 0x00, 0x62, 0xa3, 0x00, 0x01, 0x18, 0x01, 0x08, 0x03, 0x00,
0x80, 0xc0, 0x08, 0x40, 0x03, 0x80, 0x01, 0x86, 0x90, 0xc0, 0x01, 0x20, 0x01, 0x0c, 0x00, 0xc0,
0x61, 0x80, 0x10, 0x60, 0x01, 0x80, 0x03, 0x04, 0x90, 0x20, 0x00, 0xc0, 0x02, 0x04, 0x00, 0x63,
0x3a, 0x00, 0x30, 0x20, 0x00, 0xc0, 0x0c, 0x08, 0x88, 0x18, 0x00, 0x80, 0x06, 0x02, 0x00, 0x3e,
0x0e, 0x00, 0x20, 0x30, 0x01, 0xe0, 0x38, 0x08, 0x8c, 0x0e, 0x01, 0x80, 0x04, 0x02, 0x00, 0x18,
0x0f, 0x00, 0x40, 0x10, 0x01, 0x20, 0x60, 0x10, 0x84, 0x03, 0x03, 0xc0, 0x0c, 0x01, 0x00, 0x68,
0x08, 0xc0, 0x40, 0x08, 0x03, 0x11, 0x80, 0x30, 0x86, 0x00, 0xc2, 0x40, 0x08, 0x01, 0x01, 0x84,
0x10, 0x30, 0x80, 0x04, 0x02, 0x1e, 0x00, 0x20, 0x83, 0x00, 0x1c, 0x20, 0x10, 0x00, 0x86, 0x02,
0x20, 0x1d, 0x00, 0x04, 0x04, 0x18, 0x00, 0x40, 0x81, 0x00, 0x0c, 0x20, 0x20, 0x00, 0x5c, 0x02,
0x20, 0x07, 0x00, 0x02, 0x0c, 0x6c, 0x00, 0xc0, 0x81, 0x80, 0x0b, 0x10, 0x20, 0x00, 0x70, 0x01,
0x40, 0x03, 0x80, 0x03, 0x08, 0xc4, 0x00, 0x80, 0x80, 0x80, 0x19, 0x98, 0x40, 0x00, 0xe0, 0x01,
0x40, 0x06, 0x60, 0x01, 0x13, 0x04, 0x01, 0x80, 0x80, 0x40, 0x10, 0x68, 0x40, 0x03, 0xb0, 0x00
],
[
0x00, 0x60, 0x70, 0x01, 0x80, 0x03, 0xe0, 0x42, 0x43, 0x0e, 0x80, 0x00, 0xc0, 0x00, 0xec, 0x00,
0x00, 0x21, 0xc0, 0x00, 0x80, 0x01, 0xb8, 0x43, 0xc3, 0x19, 0x80, 0x01, 0x80, 0x00, 0x3c, 0x00,
0x00, 0x37, 0x00, 0x00, 0xc0, 0x01, 0x8e, 0x41, 0xc2, 0x71, 0x00, 0x01, 0x00, 0x00, 0x1c, 0x00,
0x00, 0x1c, 0x00, 0x00, 0x60, 0x00, 0xc7, 0x41, 0x82, 0xc3, 0x00, 0x03, 0x00, 0x00, 0x1e, 0x00,
0x00, 0x38, 0x00, 0x00, 0x30, 0x00, 0xc1, 0xc1, 0x83, 0x83, 0x00, 0x06, 0x00, 0x00, 0x31, 0x80,
0x00, 0x78, 0x00, 0x00, 0x18, 0x00, 0x60, 0xe1, 0x87, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x20, 0xc0,
0x00, 0xcc, 0x00, 0x00, 0x18, 0x00, 0x20, 0x71, 0xce, 0x04, 0x00, 0x18, 0x00, 0x00, 0x60, 0x60,
0x01, 0x86, 0x00, 0x00, 0x0c, 0x00, 0x30, 0x3b, 0xde, 0x0c, 0x00, 0x30, 0x00, 0x00, 0xc0, 0x30,
0x03, 0x02, 0x00, 0x00, 0x07, 0x00, 0x18, 0x3f, 0x7e, 0x18, 0x20, 0x60, 0x00, 0x00, 0x80, 0x18,
0x06, 0x03, 0x00, 0x00, 0x03, 0x9f, 0xfc, 0x37, 0x74, 0x3f, 0xff, 0xf0, 0x00, 0x01, 0x80, 0x0c,
0x0c, 0x01, 0x80, 0x00, 0x03, 0xff, 0xff, 0xb3, 0x6f, 0xf8, 0x01, 0xfe, 0x00, 0x03, 0x00, 0x06,
0x18, 0x00, 0xc0, 0x00, 0x3f, 0x60, 0x03, 0xf3, 0xef, 0xe0, 0x03, 0x03, 0xc0, 0x06, 0x00, 0x02,
0x10, 0x00, 0x60, 0x00, 0xf0, 0x38, 0x03, 0x1f, 0xfc, 0xc0, 0x0e, 0x00, 0xf0, 0x0c, 0x00, 0x03,
0x30, 0x00, 0x30, 0x03, 0x80, 0x0e, 0x01, 0xcf, 0xf9, 0x80, 0x38, 0x00, 0x1c, 0x18, 0x00, 0x01,
0x60, 0x00, 0x18, 0x0e, 0x00, 0x07, 0x80, 0xff, 0xff, 0xc0, 0xe0, 0x00, 0x07, 0x30, 0x00, 0x00,
0x40, 0x00, 0x0c, 0x38, 0x00, 0x01, 0xe7, 0xfe, 0x7f, 0xfb, 0x80, 0x00, 0x01, 0xe0, 0x00, 0x00,
0xc0, 0x00, 0x06, 0x60, 0x00, 0x00, 0x3e, 0x1e, 0x3c, 0x1f, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00,
0x80, 0x00, 0x03, 0xc0, 0x00, 0x00, 0xff, 0xfe, 0x3f, 0xfb, 0xc0, 0x00, 0x07, 0x70, 0x00, 0x01,
0x80, 0x00, 0x03, 0xe0, 0x00, 0x03, 0xc0, 0xff, 0xff, 0x80, 0x70, 0x00, 0x0c, 0x18, 0x00, 0x01,
0x80, 0x00, 0x06, 0x70, 0x00, 0x07, 0x00, 0xcf, 0xf9, 0xc0, 0x1c, 0x00, 0x38, 0x0c, 0x00, 0x03,
0xc0, 0x00, 0x0c, 0x1e, 0x00, 0x1c, 0x01, 0x9f, 0xfc, 0xe0, 0x06, 0x01, 0xe0, 0x06, 0x00, 0x06,
0x40, 0x00, 0x18, 0x07, 0x80, 0x30, 0x03, 0x3b, 0xef, 0xf0, 0x03, 0x8f, 0x80, 0x03, 0x00, 0x06,
0x60, 0x00, 0x30, 0x00, 0xf8, 0xe0, 0x07, 0xf3, 0x67, 0xfc, 0x01, 0xfc, 0x00, 0x01, 0x80, 0x0c,
0x30, 0x00, 0x60, 0x00, 0x1f, 0xe1, 0xff, 0x33, 0x76, 0x1f, 0xff, 0xe0, 0x00, 0x00, 0xc0, 0x18,
0x18, 0x00, 0xc0, 0x00, 0x03, 0xff, 0xf8, 0x37, 0x7a, 0x0c, 0x00, 0x30, 0x00, 0x00, 0xc0, 0x30,
0x0c, 0x00, 0x80, 0x00, 0x06, 0x00, 0x18, 0x2d, 0x6e, 0x06, 0x00, 0x18, 0x00, 0x00, 0x60, 0x60,
0x06, 0x01, 0x80, 0x00, 0x0c, 0x00, 0x30, 0x39, 0x47, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x30, 0xc0,
0x03, 0x03, 0x00, 0x00, 0x18, 0x00, 0x20, 0x71, 0xc3, 0x03, 0x00, 0x06, 0x00, 0x00, 0x11, 0x80,
0x01, 0x82, 0x00, 0x00, 0x10, 0x00, 0x60, 0x61, 0xc1, 0x81, 0x80, 0x03, 0x00, 0x00, 0x1f, 0x00,
0x00, 0xc6, 0x00, 0x00, 0x30, 0x00, 0xc1, 0xe0, 0xc1, 0xe0, 0x80, 0x01, 0x00, 0x00, 0x0e, 0x00,
0x00, 0x74, 0x00, 0x00, 0x60, 0x00, 0xc3, 0x60, 0xc1, 0x30, 0xc0, 0x01, 0x80, 0x00, 0x3c, 0x00,
0x00, 0x1c, 0x00, 0x00, 0x40, 0x01, 0x8e, 0x41, 0xc1, 0x9c, 0x40, 0x00, 0xc0, 0x00, 0x74, 0x00
],
]

def __init__(self, pages: list):
duration_options = list(range(0, 10000, 100))
duration_options[0] = 10
Expand Down Expand Up @@ -580,7 +440,7 @@ def _display_menu(self):
if self._current_page != len(self._pages) - 1:
self.arrow(2, 5, self.DIRECTION_RIGHT, colour=0)

self.centred_text_line(f'IN[{current_page["input"]}] OUT[{current_page["output"]}]', 2, 0)
self.centred_text_line(f'{current_page["input"]}', 2, 0)

# Show currently hovered or selected setting
if not self._current_setting:
Expand Down Expand Up @@ -623,7 +483,6 @@ def main(self):
self._is_menu_opened = False

oled.fill(0)
oled.blit(framebuf.FrameBuffer(bytearray(choice(self.SCREENSAVERS)), 128, 32, framebuf.MONO_HLSB), 0, 0)
oled.show()
return

Expand Down Expand Up @@ -663,44 +522,23 @@ def main(self):


class Karma(EuroPiScript):
ANALOG_THRESHOLD = 0.9

MIX_TYPE_NONE = 0
MIX_TYPE_OR = 1
MIX_TYPE_XOR = 2
MIX_TYPE_AND = 3
ANALOG_THRESHOLD = 0.3

def __init__(self):
super().__init__()

self._ain_current_state = LOW
self._ain_previous_state = LOW
self._previous_mix = [LOW, LOW, LOW, LOW]

self._sections = [
[KarmaOutput(cv1), KarmaOutput(cv4)],
[KarmaOutput(cv3), KarmaOutput(cv6)],
]

self._mixers = [
{
'cv': cv2,
'mix': self._sections[0],
'previous_mix': LOW,
'type': self.MIX_TYPE_OR,
},
{
'cv': cv5,
'mix': self._sections[1],
'previous_mix': LOW,
'type': self.MIX_TYPE_XOR,
},
self._output = [
KarmaOutput(cv1),
KarmaOutput(cv4),
]

self._display = KarmaDisplay([
{'cv': self._sections[0][0], 'output': '1', 'input': 1},
{'cv': self._sections[0][1], 'output': '4', 'input': 1},
{'cv': self._sections[1][0], 'output': '3', 'input': 2},
{'cv': self._sections[1][1], 'output': '6', 'input': 2},
{'cv': self._output[0], 'input': 'din'},
{'cv': self._output[1], 'input': 'ain'},
])

@b1.handler_falling
Expand All @@ -713,55 +551,50 @@ def b2_pressed():

@din.handler
def din_started():
self.start_section(0)
self._output[0].start()

@din.handler_falling
def din_ended():
self.end_section(0)

def start_section(self, section: int):
for cv in self._sections[section]:
cv.start()

def end_section(self, section: int):
for cv in self._sections[section]:
cv.end()
self._output[0].end()

def main(self):
while True:
# Emulate din.handler and din.handler_falling for ain so that it can be used as a din2
self._ain_current_state = HIGH if ain.percent() > self.ANALOG_THRESHOLD else LOW

if self._ain_current_state == HIGH and self._ain_previous_state == LOW:
self.start_section(1)
self._output[1].start()

if self._ain_current_state == LOW and self._ain_previous_state == HIGH:
self.end_section(1)
self._output[1].end()

self._ain_previous_state = self._ain_current_state

# Let each output do their thing
for section in self._sections:
for cv in section:
cv.main()

# Output the mix
for mixer in self._mixers:
if mixer['type'] == self.MIX_TYPE_OR:
mix = mixer['mix'][0].output or mixer['mix'][1].output
elif mixer['type'] == self.MIX_TYPE_XOR:
mix = mixer['mix'][0].output != mixer['mix'][1].output
elif mixer['type'] == self.MIX_TYPE_AND:
mix = mixer['mix'][0].output and mixer['mix'][1].output
else:
mix = LOW

if mix != mixer['previous_mix']:
mixer['cv'].value(mix)
mixer['previous_mix'] = mix
for output in self._output:
output.main()

# Output different mix
# CV2 = generated output 1 OR gate 1
# CV3 = generated output 1 OR generated output 2
# CV5 = generated output 2 OR gate 2
# CV6 = generated output 1 XOR generated output 2
mix = [
self._output[0].output or din.value(),
self._output[0].output or self._output[1].output,
self._output[1].output or self._ain_current_state,
self._output[0].output != self._output[1].output,
]

if mix != self._previous_mix:
self._previous_mix = mix

for index, cv in enumerate([cv2, cv3, cv5, cv6]):
cv.value(HIGH if mix[index] else LOW)

self._display.main()


if __name__ == '__main__':
Karma().main()

0 comments on commit cdc827f

Please sign in to comment.