coding dojo - the learning remote control
TRANSCRIPT
Coding Dojo
The learning remote control/* a C++ exercise */
@AlinPandichi
Coding Dojo Mindset●We are here to learn●Safe place outside of work●Need to slow down●Focus on doing it right●Noncompetitive, collaborative, fun environment
Agenda
●19:00 19:10 Introduction ●19:10 19:30 Intro●19:30 20:00 Practice Session Part 1 ●20:00 20:10 Break ●20:10 20:45 Practice Session Part 2 ●20:45 21:00 Retrospective
The learning remote control
● You are writing the firmware for a learning remote control.
● You put it into a 'listening' state...● ...to capture the signal from another IR remote control
● Your firmware must find a repeating pattern of pulses
Digital signal processing
● https://www.allaboutcircuits.com/uploads/articles/AnIntroductiontoDigitalSignalProcessing(1).png
Other requirements● on_start_learning_mode to simulate the user initiating a training operation
● on_signal_change called repeatedly to simulate a continually repeating input signal
● Return a list of pulses representing the detected pattern (or none)
Other requirements● A pulse is defined as a HIGH/LOW pair made out of an integer 2tuple.
● Each integer pair is the time in nanoseconds the signal was high for and then the time in nanoseconds the signal was low for. For example:
# high for 52 nanos, low for 4500 nanospulse = (52, 4500)
In ASCII art...
| (1) (2) (3)(4)(5) (6) (7)(8) <-- | ..................... .... ..... ... <--- HIGH| | | | | | | | ||.....| |...| |..| |.....| | <--- LOW| <- nanos_elapsed ->+-------------------------------------------------------------time_nanos ->
It should look something like this
def on_signal_change(is_high, nanos_elapse): # your code ... # then return a pattern return [(50, 4500), (3423, 333), (212,44)]
The following will hold true● The first invocation of the on_signal_change method
will be the start of the pattern. Note that nanos_elapsed will be 0 for this first call.
● The first invocation of the on_signal_change method will always be for a LOW to HIGH transition (rising edge, is_high is True).
● The pattern will be made up of at least 1 HIGH/LOW pulse.
● The pattern will be made up of less than 26 HIGH/LOW pulses.
● The pattern will be made up of ideal pulses (i.e. no jitter, fuzzyness, or drift).
Practice session
● One laptop with a functional dev. env. is connected to a projector
● Two developers pair program on the laptop. The others are watching the code changes.
● Every 7 minutes, one developer leaves the laptop and the next one from the room takes his place.
Kata stolen from:
https://www.codewars.com/kata/learning-remote-control/