This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LedStripController(private val supplier: LedStripSupplier) : BaseController { | |
private val leds = Led.values().filterNot { it == Led.NONE || it == Led.ALL } | |
private val ledStates = HashMap<Led, Boolean>(supplier.getLength()) | |
fun light(led: Led) { | |
when (led) { | |
Led.ALL -> putAll(true) | |
else -> ledStates.put(led, true) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LedStripSupplierImpl : LedStripSupplier { | |
private val apa102: Apa102 by lazy { | |
RainbowHat.openLedStrip().apply { | |
direction = Apa102.Direction.REVERSED | |
brightness = 7 | |
} | |
} | |
override fun getLength(): Int = RainbowHat.LEDSTRIP_LENGTH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const val TURN_OFF_COLOR = -1 | |
interface LedStripSupplier : BaseSupplier { | |
fun light(colors: IntArray) | |
fun getLength(): Int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const val MSG = 1 | |
class Timer(private val listener: Timer.Listener) { | |
interface Listener { | |
fun onTick(tick: Double) | |
fun onStart() | |
fun onStop() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GameController(private val abcButtons: AbcButtonsController, | |
private val abcLeds: AbcLedsController, | |
private val digiDisplay: DigiDisplayController, | |
private val timer: Timer, | |
private val game: Game) : AbcButton.Listener { | |
private val closeables: List<AutoCloseable> = listOf(abcButtons, abcLeds, digiDisplay) | |
init { abcButtons.setListener(this) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DoReFindMiActivity : Activity() { | |
private val abcButtonsController = AbcButtonsController(AbcButtonsSupplierImpl()) | |
private val abcLedsController = AbcLedsController(AbcLedsSupplierImpl()) | |
private val digiDisplayController = DigiDisplayController(DigiDisplaySupplierImpl()) | |
private val ledStripController = LedStripController(LedStripSupplierImpl()) | |
private val buzzerController = BuzzerController(BuzzerSupplierImpl()) | |
private val gameController: GameController by lazy { | |
GameController( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MidiControls(presenter: MidiControllerContract.Presenter) { | |
private val driver: Driver = Driver() | |
private val mcpDriverManager: McpDriverManager = McpDriverManager(presenter, driver) | |
private val midiButtonDrivers: MutableList<ButtonInputDriver> = mutableListOf() | |
private val midiButtonMapping: Map<String, Int> = mapOf( | |
driver.getBtn0() to KeyEvent.KEYCODE_0, | |
driver.getBtn1() to KeyEvent.KEYCODE_1, | |
driver.getBtn2() to KeyEvent.KEYCODE_2, | |
driver.getBtn3() to KeyEvent.KEYCODE_3 |
NewerOlder