Created
July 9, 2023 02:43
-
-
Save bettse/d6b440258c8335b15d5abfd545866740 to your computer and use it in GitHub Desktop.
Minions Bubble research
This file contains hidden or 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
import array | |
import pulseio | |
import board | |
import adafruit_irremote | |
import time | |
#from adafruit_circuitplayground import playground | |
HEADER_VAL = 6000 | |
BLACK = (0, 0, 0) | |
# Create a 'pulseio' input, to listen to infrared signals on the IR receiver | |
pulsein = pulseio.PulseIn(board.IR_RX, maxlen=120, idle_state=True) | |
# Create a decoder that will take pulses and turn them into numbers | |
decoder = adafruit_irremote.GenericDecode() | |
pulseout = pulseio.PulseOut(board.IR_TX, frequency=38000, duty_cycle=32768) | |
encoder = adafruit_irremote.GenericTransmit(header=[HEADER_VAL, 0], | |
one= [575, 550], | |
zero= [600, 1650], | |
trail=None, | |
debug=True) | |
#$ java -jar IrpTransmogrifier-1.2.10-jar-with-dependencies.jar analyze --trailinggap 6162 500 1591 481 1600 474 551 1521 1596 478 1573 500 1600 498 1573 475 529 | |
# {498,msb}<1,-1|1,-3>(A:3,3,-3,B:4){A=0x6,B=0xe} | |
# Pwm2Decoder | |
def minion_ish(pulses): | |
# Look for header and split pulses into 'messages' | |
# messages should be 16 pulses | |
if len(pulses) > 17: | |
pulses = pulses[:16] | |
if pulses[0] > HEADER_VAL * 1.1 or pulses[0] < HEADER_VAL * 0.9: | |
return [] | |
#return ["l" if b > 1000 else "s" for b in pulses[1:]] | |
return ["1" if b > 1000 else "0" for b in pulses[1:]] | |
sample = False | |
while True: | |
try: | |
pulses = decoder.read_pulses(pulsein) | |
if len(pulses) < 10 or len(pulses) > 20: | |
continue | |
#print(" ".join([str(b) for b in pulses])) | |
ish = minion_ish(pulses) | |
decimal_representation = int("".join(ish), 2) | |
hexadecimal_string = hex(decimal_representation) | |
if decimal_representation == 0x5354: | |
print("playing") | |
elif decimal_representation == 0x534d: | |
print("singing") | |
elif decimal_representation == 0x4ad2: | |
print("laughing") | |
elif decimal_representation == 0x4ad3: | |
print("raspberry") | |
elif decimal_representation == 0x4ad4: | |
print("idle") | |
pulses = array.array('H', [6114, 534, 1516, 529, 1541, 551, 504, 1566, 1521, 548, 1511, 558, 1512, 557, 1515, 556, 499]) | |
pulseout.send(pulses) | |
elif decimal_representation == 0x2d54: | |
print("reply") | |
else: | |
print("minion_ish: ", hexadecimal_string) | |
sample = True | |
except Exception as e: | |
print("exception: ", e.args) | |
continue | |
#if cp.button_a: ### left button_a | |
# pulses = array.array('H', [6114, 534, 1516, 529, 1541, 551, 504, 1566, 1521, 548, 1511, 558, 1512, 557, 1515, 556, 499]) | |
# pulseout.send(pulses) | |
# cp.pixels.fill(SHUTTER_CMD_COLOUR) | |
# while cp.button_a: | |
# pass ### wait for button release | |
#elif cp.button_b: | |
# pixel_indication = not pixel_indication | |
# while cp.button_b: | |
# pass ### wait for button release | |
This file contains hidden or 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
[5990, 502, 1537, 479, 1540, 477, 559, 1458, 1544, 473, 1517, 500, 1517, 499, 1540, 477, 558, 1485, | |
6019, 473, 1547, 470, 1547, 470, 555, 1461, 1542, 476, 1543, 475, 1544, 473, 1545, 470, 555, 2187, | |
6168, 480, 1591, 478, 1593, 475, 528, 1543, 1564, 504, 1597, 472, 1567, 500, 1591, 475, 530] | |
[6167, | |
507, 1514, | |
530, 1541, | |
553, 501, | |
1568, 1538, | |
531, 1520, | |
550, 1519, | |
550, 1541, | |
527, 508 | |
] | |
[6114, 534, 1516, 529, 1541, 551, 504, 1566, 1521, 548, 1511, 558, 1512, 557, 1515, 556, 499] | |
[6135, 528, 1541, 523, 1516, 523, 534, 1532, 1542, 548, 1512, 553, 1518, 574, 1486, 553, 502] | |
https://github.com/kevinjwalters/circuitpython-examples/blob/master/cpx/cpx-ir-shutter-remote.py | |
#sony | |
ir_encoder = adafruit_irremote.GenericTransmit(header=[2400, 600], | |
one= [1200, 600], | |
zero= [600, 600], | |
trail=None) | |
### Create an encoder for NEC IR timed pulses (in microseconds) | |
### NEC values from Adafruit example - these do work for PCS II | |
##encoder = adafruit_irremote.GenericTransmit(header=[9500, 4500], | |
## one= [550, 550], | |
## zero= [550, 1700], | |
## trail=0) | |
### Practical Colorful Series II remote for RGBW lightbulbs | |
### Observed values | |
encoder = adafruit_irremote.GenericTransmit(header=[9000, 4500], | |
one= [575, 550], | |
zero= [600, 1650], | |
trail=0) | |
https://github.com/cyborg5/IRLib2 | |
https://www.analysir.com/blog/analysir-free-download/ | |
[6162 500 1591 481 1600 474 551 1521 1596 478 1573 500 1600 498 1573 475 529] | |
m s m s m s m s m s m s m s m s m | |
$ java -jar IrpTransmogrifier-1.2.10-jar-with-dependencies.jar analyze --trailinggap 6162 500 1591 481 1600 474 551 1521 1596 478 1573 500 1600 498 1573 475 529 | |
{498,msb}<1,-1|1,-3>(A:3,3,-3,B:4){A=0x6,B=0xe} | |
Pwm2Decoder | |
[6163 528 1573 500 1571 502 553 1520 1576 499 1572 502 1549 526 1576 498 557] | |
[6184 480 1550 525 1598 477 559 1516 1549 526 1566 508 1572 502 1599 476 560] | |
[6156 507 1542 530 1572 502 563 1511 1576 499 1540 534 1568 504 1576 498 558] | |
[6162 505 1596 477 1594 481 533 1541 1596 479 1603 471 1599 477 1594 481 533] | |
sm mm sm mm sm ss sm mm sm mm sm mm sm mm sm | |
0 1 0 1 0 0 1 0 1 0 1 0 1 0 | |
---- | |
exception: (IRMessage(pulses=( | |
6032, 473, 1493, 528, 1512, 510, 536, 1484, 1518, 504, 1516, 505, 1514, 508, 1521, 499, 505, 1517, | |
5997, 534, 1495, 526, 1493, 528, 539, 1457, 1545, 502, 1518, 503, 1495, 527, 1493, 530, 505, 2216, | |
6159, 525, 1514, 558, 1513, 560, 506, 1540, 1545, 554, 1517, 555, 1514, 558, 1544, 528, 506 | |
), reason='Both even/odd pulses differ'),) | |
[6193, 473, 1567, 508, 1593, 482, 564, 1511, 1573, 502, 1568, 506, 1566, 509, 1571, 504, 561] | |
[6187, 502, 1568, 506, 1576, 498, 536, 1538, 1567, 481, 1568, 532, 1569, 505, 1575, 498, 527] | |
[6156, 508, 1593, 480, 1571, 504, 560, 1514, 1571, 502, 1569, 507, 1564, 508, 1572, 503, 564] #len 17 | |
exception: (IRMessage(pulses=(6038, 472, 1516, 506, 539, 1484, 535, 1462, 558, 1465, 1517, 531, 1518, 506, 1544, 478, 536), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6004, 505, 1514, 508, 537, 1485, 533, 1490, 539, 1484, 1519, 504, 1516, 507, 1522, 500, 534), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6005, 478, 1522, 525, 509, 1513, 535, 1462, 537, 1486, 1518, 502, 1546, 502, 1497, 500, 555), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6031, 479, 1540, 483, 532, 1490, 559, 1462, 537, 1485, 1547, 502, 1497, 498, 1520, 504, 533), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6036, 473, 1546, 477, 506, 1516, 503, 1520, 530, 1493, 1521, 501, 1518, 531, 1499, 499, 504), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6034, 474, 1546, 477, 538, 1458, 561, 1462, 557, 1466, 1548, 475, 1524, 500, 1519, 502, 564), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6003, 505, 1524, 499, 558, 1465, 532, 1490, 530, 1493, 1520, 502, 1549, 474, 1544, 478, 537), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6004, 505, 1546, 476, 537, 1485, 535, 1490, 528, 1493, 1541, 481, 1548, 476, 1524, 499, 535), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6037, 472, 1517, 505, 530, 1492, 505, 1517, 513, 1536, 1498, 525, 1494, 503, 1516, 506, 530), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6032, 478, 1541, 481, 502, 1520, 531, 1491, 537, 1486, 1518, 503, 1515, 507, 1522, 527, 508), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6005, 504, 1516, 507, 507, 1516, 534, 1463, 557, 1466, 1516, 532, 1497, 525, 1514, 508, 537), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6029, 480, 1518, 504, 531, 1492, 537, 1486, 534, 1487, 1494, 529, 1521, 501, 1518, 504, 531), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6034, 474, 1523, 500, 535, 1487, 564, 1459, 529, 1495, 1549, 472, 1547, 476, 1543, 479, 556), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6031, 478, 1520, 503, 532, 1491, 508, 1514, 505, 1518, 1548, 475, 1545, 478, 1522, 501, 534), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6003, 505, 1515, 508, 507, 1516, 512, 1510, 510, 1513, 1521, 502, 1517, 508, 1512, 511, 504), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6036, 474, 1514, 508, 527, 1497, 502, 1521, 509, 1513, 1541, 481, 1548, 475, 1546, 476, 528), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6009, 501, 1517, 506, 508, 1514, 537, 1458, 559, 1464, 1520, 503, 1515, 533, 1497, 526, 529), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6004, 479, 1521, 502, 563, 1460, 559, 1463, 536, 1486, 1547, 475, 1544, 479, 1541, 481, 563), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6035, 476, 1512, 511, 535, 1488, 511, 1512, 539, 1484, 1489, 534, 1515, 507, 1544, 479, 504), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6006, 503, 1516, 506, 529, 1494, 535, 1487, 533, 1490, 1544, 479, 1550, 473, 1547, 474, 529), reason='Both even/odd pulses differ'),) | |
exception: (IRMessage(pulses=(6008, 502, 1548, 475, 509, 1513, 536, 1486, 533, 1490, 1544, 479, 1521, 502, 1547, 476, 509), reason='Both even/odd pulses differ'),) | |
----- | |
0x5354/0x4ad4 | |
0x5354/0x4ad3/0x4ad2 | |
0x5354/0x4ad4 | |
long: 0x534d/0x2d4d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment