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
| // This DTS overlay sets up one input and one output pin for use by | |
| // PRU0 via its Enhanced GPIO mode, which will let us access those pins | |
| // by writing to R30 bit 15 or reading from R31 bit 14. | |
| // Save this file wherever you want (but I recommend /lib/firmware), as | |
| // "PRU-GPIO-EXAMPLE-00A0.dts". | |
| // Compile with: | |
| // dtc -O dtb -I dts -o /lib/firmware/PRU-GPIO-EXAMPLE-00A0.dtbo -b 0 -@ PRU-GPIO-EXAMPLE-00A0.dts | |
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 math | |
| # 8087 tangent algorithm, from Implementing Transcendental Functions, R. Nave | |
| atan_table = [math.atan(2 ** -i) for i in range(0, 17)] | |
| def cordic_tan(z): | |
| # Compute tan of angle z, using CORDIC | |
| q = [] | |
| # Break down z into sum of angles, where each angle is 0 or atan(2**-i) |
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
| # Crack Xerox Alto disk passwords using math. | |
| import sys | |
| def findPasswd(passvec): | |
| # a and b are the salt values | |
| a = (passvec[1] << 16) + passvec[2] | |
| b = (passvec[3] << 16) + passvec[4] | |
| if a == 0 or b == 0: | |
| print 'No password' |
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
| - | |
| - * | |
| - + XX | |
| - + X XXXX | |
| - + XXX XXXXX | |
| - * XXXXXX XXXXXXX | |
| - XX XXXXXXXXXXXXXXXXX | |
| - XXXX XXXXXXXXXXXXXXXXXX | |
| - * XXXXXX XXXXXXXXXXXXXXXXXXX | |
| - XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
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
| # https://www.reddit.com/r/puzzles/comments/1hjpd63/comment/m38k73k | |
| # Port of my Arc program at https://www.righto.com/2010/12/solving-edge-match-puzzles-with-arc-and.html | |
| # Ken Shirriff righto.com | |
| import math | |
| # Symbols | |
| menorah = 1 | |
| dreidel = 2 | |
| gift = 3 |
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
| d0 STR-0 Store the next byte (7) in register 0. | |
| 07 | |
| 0c SLE Skip two instructions if accumulator <= register 0. | |
| 03 DED Decrement the accumulator in decimal mode | |
| 5f NOP No operation | |
| d0 STR-0 Store the next byte (0x31) in register 0 | |
| 31 | |
| 30 SBZ-0 Skip two instruction bytes if accumulator bit 0 is zero | |
| 81 JMP-1 Jump to 0x1c9 (end of this code block) | |
| c9 |
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
| # Program to parse VGA data (EDID) accessed from I2C device 0x50 | |
| # | |
| # This is a quick demo not a supported program, so don't expect | |
| # correctness from it. | |
| # | |
| # Edid format from: | |
| # https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#EDID_1.4_data_format | |
| # | |
| # Ken Shirriff http://righto.com |
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
| /* | |
| * Demonstration of the BeagleBone's PRU, using a timer. | |
| * Ken Shirriff, http://righto.com | |
| */ | |
| #include <stdint.h> | |
| #define DELAY_NS 100 // Use 500000000 for 0.5 second delay | |
| #define WRITE_PIN 15 /* P8_11, Ethernet output data, pr1_PRU0_pru_r30_15 */ | |
| // PRU Interrupt control registers |
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
| # This code prints out the melody in the UM66T sound chip's ROM. | |
| # The ROM holds Jingle Bells, Santa Claus is Coming to Town, and We Wish You a Merry Christmas. | |
| # See this Twitter thread for details: https://twitter.com/kenshirriff/status/1472297415201869831 | |
| from collections import defaultdict | |
| notes = ['X', 'X', 'G4', 'A5', 'B5', 'C5', 'D5', 'E5', 'F5', 'G5', 'A6', 'B6', 'C6', 'X', 'X', 'X'] | |
| # Hard-coded ROM contents. | |
| bits = {"24,1":0,"15,0":1,"15,1":0,"15,3":1,"15,4":0,"14,4":1,"13,4":0,"12,4":1,"11,4":0,"10,4":1,"9,4":1,"8,4":0,"7,4":0,"6,4":1,"5,4":1,"4,4":0,"0,4":0,"1,4":1,"2,4":1,"3,4":0,"0,1":1,"0,0":1,"3,0":1,"4,0":1,"7,0":1,"8,0":1,"11,0":1,"12,0":1,"17,0":1,"19,0":1,"20,0":1,"23,0":1,"25,0":1,"26,0":1,"29,0":1,"31,0":1,"30,1":1,"28,1":1,"26,1":1,"25,1":1,"22,1":1,"21,1":1,"18,1":1,"17,1":1,"30,5":1,"31,6":1,"30,8":1,"30,9":1,"30,10":1,"31,11":1,"31,13":1,"31,14":1,"30,15":1,"31,16":1,"30,18":1,"30,19":1,"31,20":1,"31,21":1,"30,23":1,"31,24":1,"31,25":1,"31,26":1,"31,28":1,"30,29":1,"30,28":0,"29, |
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
| #!/usr/bin/python | |
| """ Download an IR remote signal from a Rigol DS1052E and | |
| analyze it for a NEC protocol signal. | |
| Ken Shirriff | |
| http://righto.com | |
| """ | |
| import array | |
| import sys |
NewerOlder