Base metal IR test program with sleep mode
Pre-release
Pre-release
Assumes factory default fuses (runs at 1Mhz).
/*
- SimpleIRTest.cpp
- This is the simplest possible IR test program.
- Is accesses the blink hardware directly with no interrupts and requires no library code (runs bare metal).
- It has three modes: TX, RX, and sleep
- TX mode
- =======
- Blink sends an IR pulse every 1ms on face IR0.
- The RGB LED on P0 shows green to indicate TX mode.
- Pushing button cycles though pulse transmitted pulse width.
- The pulse width is indicated by the number of BLUE LEDS lit:
- 1 blue = 5us
- 2 blue = 7us
- 3 blue = 10us
- 4 blue = 12us
- 5 blue = 15us
- The 'A' pin on the service port connector goes high while the IR LED is on.
- Pressing the button after the widest pulse width switches to RX mode
- RX mode
- =======
- Blink listens for an IR pulse on face IR0 every 2ms on face IR0.
- The RGB LED on face P0 shows RED to indicate RX.
- The time since the last trigger is indicated by which BLUE LEDS lit:
- P2 Cyan = <650us (Too short)
- P3 Blue = >650us and <950us (Just right)
- P4 Magenta = >950us (Too long)
- The 'A' pin on the service port connector pulses high when the IR0 LED is triggered. This pulse width is fixed and
- only indicates that a trigger happened.
- Pressing the button in RX mode goes to sleep mode
- SLEEP MODE
- ==========
- Blink goes into low power sleep.
- Pressing the button in sleep mode wakes the blink and goes to TX mode
- Usage
- =====
- You can cycle between modes and TX mode pulse times by pressing and releasing the button.
- Put one blink in TX mode and select a pulse width. Put another blink in RX mode. Aim their IR0 faces together.
- For the blink in RTX mode...
- P2 Cyan indicates that the IR LED is triggering by ambient light before the pulse arrives, or something is touching the LED
- P3 Blue indicates that pulses with expected timing are being received
- P4 Magenta in Rx mode indicates that some TX pulses are being missed
- Each of these indications will stay lit for about 0.1 second after the event so you can see it.
- If only P5 on RX lights then this is a good sign that good communication is possible.
- Connect an oscilloscope to the A pin on both blinks. Trigger on the A pin from the TX blink and watch to
- see how long it takes for the RX to trigger after the TX pulse is sent.
- Watch for the min and max of the timing between the RX and TX going high on pin A of the two blinks
- Short and consistent times are good.
*/