XR10 Open Source Drum Module

The XR10 drum module is now open source.

Here you will find code, gerber files for the PCB and template file for the panel.

The XR10 is an Electro Percussion module in 12HP.
6 classic electro/hip-hop sounds with separate outputs.

Features:

  • 6 classic XR10 drum sounds.
  • 6 voice polyphonic
  • 6 slider knob volume mixer
  • 6 tuning knobs 4 – 40 KHz sample frequency
  • 6 separate drum outputs
  • 1 mixed mono output

The XR10 is built on a 12HP (61mm) PCB using the ATmega328 as the main drum chip.

BOM for the build:

  • Alu panel
  • PCB
  • Drum chip
  • 13pcs Thonkiconn jacks
  • 6pcs 20mm slider potentiometer
  • 6pcs 9mm rotary potentiometer
  • 10-pin IDC power connector
  • 78L05 linear regulator
  • 7pcs 10uF electrolythic capacitor
  • 7pcs 100nF ceramic capacitor
  • 12pcs 1K resistor
  • 7pcs 1N4148 diodes

Schematics

Building Instructions

1. Solder the 10-pin IDC power connector and the chip (or a socket)

2. Solder D1-D7 diodes. Mind the polarity

3. Solder the R1-R12 resistors

4. Solder the C1-C6 & C13 ceramic capacitors

5. Solder the C7-C12 & C14 electrolythic capacitors. Mind the polarity

6. Solder the IC2 linear regulator

7. Flip the board over and solder the CN1-CN13 Thonkiconn jacks

8. Solder the POT7-POT12 slider potentiometers

9. Solder the POT1 potentiometer

10. Cut the left support leg of POT2-6 potentiometer

11. Solder the POT2-6 potentiometer

12. Mount the panel and tighten the nuts for the Thonkiconn jacks with your fingers. DO NOT use a tool.

13. Finished. Mount it in your eurorack and drum away.

Parts for the build

If you have trouble with making PCB’s, programming chips or cutting aluminum panels your self these parts can be bought here:

Parts for the XR10 build 

XR10 DIY Full kit

And the thonkiconn jacks and potentiometers

Jacks and rotary potentiometers

And the slider potentiometers

20mm slider potentiometers

Gerber files for the PCB can be downloaded here.
Send the zip file to a PCB manufacturer.

Download PCB Gerber Files

The panel is screen printed and cut in 1.5mm aluminum.

Download the panel design

The code for the ATmega is programmable with the Arduino IDE and also runs unmodified on the Arduino Uno & Nano.

Download the XR10 INO-sketch


/* Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documnetation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to  whom the Software is
 * furished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>

#define F_CPU 15271212
#define USART_BAUDRATE 31250 
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

const unsigned char PS_2 = (1 << ADPS0);;
const unsigned char PS_4 = (1 << ADPS1);
const unsigned char PS_8 = (1 << ADPS1) | (1 << ADPS0);
const unsigned char PS_16 = (1 << ADPS2);
const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0);
const unsigned char PS_64 = (1 << ADPS2) | (1 << ADPS1);
const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); #ifndef cbi #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #endif #ifndef sbi #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #endif // Standard Arduino Pins #define digitalPinToPortReg(P) \ (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC)) #define digitalPinToDDRReg(P) \ (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC)) #define digitalPinToPINReg(P) \ (((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC)) #define digitalPinToBit(P) \ (((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (P) - 14)) #define digitalReadFast(P) bitRead(*digitalPinToPINReg(P), digitalPinToBit(P)) #define digitalWriteFast(P, V) bitWrite(*digitalPinToPortReg(P), digitalPinToBit(P), (V)) #define TOGD2 PORTD ^= 4 const uint8_t BD[] PROGMEM = { 127,124,115,109,116,110,103,104,97,96,92,89,91,88,89,85,81,78,71,64,65,67,68,64,62,65,66,64,65,62,62,62,64,64,66,66,68,69,70,71,72,72,74,78, 83,79,84,87,72,95,122,136,70,75,96,110,192,248,226,129,86,108,151,211,208,152,166,200,220,211,185,187,200,195,202,212,213,218,223,226,230,233,235,234,232,231,230,228,227,226,224,223,221,221,219,218,216,215,214,213,211,211,209,208,207,206,204,203,189,124,25,39,140,202,206,202,194,164,148,165,168,155,161,163,151,129,109,105,133,162,171,124,85,100,118,126,109,93,110,111,92,86,95,106, 103,87,85,93,81,77,83,93,88,73,69,65,67,74,70,54,53,65,59,56,64,60,44,54,80,80,60,48,49,51,53,53,53,55,56,58,58,58,60,61,62,63,64,65,66,67,67,68,70,71,71,73,74,76,77,75,77,82,93,93,76,80,82,81,85,88,85,83,87,86,87,88,89,90,90,91,92,93,93,94,94,96,96,97,104,124,117,79,113,131,131,85,100,106,97,106,100,107,103,107, 105,108,106,109,108,110,109,111,110,112,111,113,113,114,114,115,115,116,117,127,149,150,119,117,136,123,110,128,131,139,140,143,141,140,140,119,122,146,180,195,181,177,176,149,127,166,193,172,182,200,199,192,186,194,207,215,224,224,226,221,212,200,201,218,229,238,236,226,217,214,231,245,233,231,247,255,247,248,245,241,240,240,248,247,233,227,240,240,224,219,224,232,238,233,232,231,229,228,226,225, 224,222,221,220,219,218,216,215,214,212,211,210,209,208,206,205,204,203,202,201,200,198,197,196,195,194,193,192,191,190,185,176,174,190,184,171,170,184,180,151,138,144,156,151,134,111,104,127,143,136,134,110,77,76,96,112,122,127,110,74,53,51,73,122,124,92,92,106,97,87,82,79,83,79,70,72,83,83,80,80,90,95,83,72,70,89,113,108,100,91,82,94,115,126,117,115,109,106,107,121, 135,139,144,138,122,117,123,131,148,139,119,111,114,125,137,129,113,117,141,151,146,137,140,140,127,119,127,147,144,121,114,123,124,126,127,129,127,122,110,103,118,120,110,111,126,130,111,105,118,121,113,106,107,128,130,109,98,101,102,91,102,119,110,91,88,100,106,96,98,108,109,105,90,86,96,106,102,101,112,119,101,81,79,87,101,106,94,80,82,87,88,89,92,88,85,94,90,76,76,84, 83,89,88,77,67,68,73,78,79,69,60,66,76,77,78,70,69,84,92,79,71,70,68,65,66,71,70,63,73,84,83,76,66,57,52,66,77,65,58,63,59,54,56,63,69,65,58,56,55,60,62,55,57,62,61,60,61,62,63,64,65,66,66,68,72,79,73,68,77,79,75,73,76,76,77,78,79,80,80,81,82,83,83,85,89,93,89,93,94,92,94,89,92,97,108,108,100,111,119,113, 108,109,116,120,120,122,119,119,126,132,129,122,124,121,124,136,147,154,143,126,122,130,138,147,153,150,149,155,156,159,159,156,155,154,152,156,161,158,154,156,164,171,166,163,169,178,175,168,168,169,176,181,175,174,180,178,173,170,179,181,180,186,178,181,191,192,190,189,183,187,198,203,207,201,194,198,198,198,208,209,206,212,217,220,216,214,221,216,215,221,215,220,226,219,208,212,218,208,208,217, 218,215,214,211,208,210,211,208,208,206,205,204,203,202,201,199,198,197,196,196,195,194,192,191,189,188,185,186,188,184,185,183,182,182,180,176,170,169,172,174,175,172,169,172,170,166,161,159,158,151,144,142,150,151,141,138,144,145,138,135,135,129,121,119,126,131,131,120,109,105,103,113,122,116,111,111,98,92,99,95,91,91,96,102,100,90,81,81,82,83,79,78,81,88,88,77,72,73,70,71, 70,64,59,65,68,69,70,68,68,62,54,55,59,61,66,66,69,72,67,65,64,56,53,59,69,72,70,79,84,79,76,80,82,87,87,87,86,89,98,104,103,106,101,99,105,107,103,103,112,117,119,113,114,126,133,135,135,130,128,127,130,128,127,132,143,145,139,134,129,132,138,145,144,135,133,136,142,143,135,128,133,132,131,133,128,117,117,126,131,126,122,119,115,119,120,114,112,115,114,112, 110,113,111,102,101,107,111,108,100,97,96,96,99,102,101,102,101,93,87,87,91,95,98,92,91,87,86,87,87,86,91,92,83,84,91,89,84,83,85,88,94,95,91,90,87,85,84,86,91,97,96,97,100,95,95,98,95,94,97,106,112,110,107,106,108,115,120,117,111,112,120,127,128,126,124,127,129,127,130,131,129,131,139,140,137,135,137,141,141,138,138,139,140,139,137,136,139,143,144,143, 141,145,142,135,133,137,141,138,134,137,139,132,129,128,125,127,131,131,135,140,133,123,127,132,130,126,124,127,128,127,124,118,115,114,122,127,125,122,121,119,119,125,123,114,111,113,116,114,108,112,117,116,116,116,115,115,117,116,110,105,109,119,121,112,111,117,118,120,115,110,113,116,114,119,120,117,119,118,114,116,118,122,123,120,119,120,120,116,116,118,116,116,117,118,123,125,122,123,123,121, 117,114,118,126,126,118,118,121,122,127,128,122,118,122,124,126,125,121,119,121,122,122,122,120,120,127,131,133,134,128,126,130,131,128,130,137,140,138,134,134,135,136,140,142,139,137,140,146,148,147,144,142,148,152,150,145,143,145,149,150,150,152,154,154,152,147,150,158,159,162,163,157,152,155,159,159,155,152,154,159,161,159,154,154,159,161,159,157,158,154,151,153,153,149,147,150,155,155,152,150, 153,153,150,145,143,144,145,147,145,142,139,137,141,144,145,142,138,135,134,134,132,131,131,129,128,132,132,131,128,125,124,122,124,128,128,124,122,119,117,117,121,123,124,125,124,121,124,126,121,120,122,122,121,123,124,123,124,124,124,124,124,124,126,126,124,126,125,124,128,127,129,132,132,132,132,130,128,130,135,138,135,134,134,135,134,135,139,142,141,139,136,136,140,144,144,144,142,139,140,141, 142,143,141,141,142,143,143,145,145,146,146,145,146,148,147,144,146,147,146,145,145,149,149,147,147,148,146,143,143,141,145,149,147,146,146,146,146,144,144,144,144,144,143,143,142,138,136,139,141,140,137,134,136,138,136,135,133,133,134,134,132,128,127,125,121,122,128,131,124,121,122,122,118,118,121,122,122,120,117,119,119,116,113,114,116,118,117,116,117,116,114,112,112,112,111,113,115,114,111,110, 113,113,112,113,114,115,116,116,116,115,114,114,115,117,116,114,116,121,126,126,122,120,123,125,124,123,124,126,129,130,129,130,128,130,131,132,135,133,128,128,131,133,134,135,135,136,138,135,132,133,134,135,134,133,133,134,135,136,136,137,137,135,135,136,135,134,132,132,130,132,135,133,134,135,134,135,132,129,129,130,129,129,131,131,129,130,133,133,130,126,127,128,130,130,127,125,130,132,130,128, 129,129,128,129,128,125,127,130,128,126,127,128,129,131,129,128,128,127,125,126,129,131,130,130,128,127,129,130,131,131,130,130,133,135,132,128,129,130,131,134,135,132,129,132,134,136,134,131,134,135,135,135,135,133,132,133,133,134,136,135,133,131,129,131,134,135,134,132,132,131,130,129,129,129,128,126,126,127,127,127,127,128,126,123,121,123,126,126,125,123,120,120,120,121,123,122,120,118,116,116, 117,116,116,115,116,116,116,116,113,111,113,116,118,119,117,115,115,115,116,117,115,113,113,116,117,118,119,117,115,115,115,116,118,118,117,118,118,118,120,120,119,117,115,116,118,118,120,123,123,120,119,118,118,118,118,120,123,125,125,123,121,120,121,124,123,122,122,124,126,126,126,127,127,123,123,127,130,130,129,130,130,128,128,128,129,129,129,130,132,132,131,133,133,132,135,137,136,136,136,136, 136,139,138,136,137,137,136,138,138,137,138,136,137,138,139,138,137,135,135,136,135,136,136,136,136,137,137,136,136,137,136,136,136,136,136,136,135,135,136,136,135,136,136,136,134,133,133,135,135,137,137,136,135,133,133,135,136,136,136,134,134,137,137,136,137,137,136,135,137,138,135,136,137,136,138,139,138,139,137,136,137,137,136,136,138,139,138,137,137,138,135,135,136,136,138,140,140,138,136,137, 137,136,136,137,139,138,136,136,137,137,137,135,136,137,137,137,136,134,134,135,135,136,137,136,134,134,134,132,132,133,133,134,132,132,133,132,132,131,130,131,131,132,132,129,130,131,130,129,128,128,128,127,128,129,129,128,127,126,126,126,126,127,126,125,126,128,127,127,127,128,128,126,126,126,128,129,128,128,127,126,128,129,128,129,130,129,128,129,130,130,130,130,130,129,129,131,132,132,132,132, 132,131,131,131,132,134,134,133,133,134,135,134,133,133,135,136,136,136,135,135,136,137,137,135,134,134,134,134,135,137,136,133,133,134,132,132,132,133,133,134,133,131,130,130,130,131,130,128,128,128,128,127,127,126,126,126,126,126,126,125,125,123,123,123,123,121,122,123,122,121,121,120,120,121,122,121,120,119,119,119,120,120,120,119,119,120,119,118,117,118,119,119,119,119,118,119,119,119,119,119, 119,121,121,121,122,122,122,123,122,122,122,123,123,123,124,124,126,127,126,124,124,126,128,128,128,129,129,130,128,127,129,129,130,131,131,131,131,131,132,131,131,132,133,133,132,133,132,131,131,132,133,133,133,132,131,130,132,133,133,133,133,133,133,132,131,132,133,133,132,131,131,131,131,131,131,131,130,130,130,129,129,131,131,130,129,128,128,128,128,128,129,127,127,127,127,127,127,126,126,126, 126,126,125,126,126,126,126,126,126,125,125,126,126,125,124,124,125,126,127,127,125,125,125,125,125,126,128,128,127,125,126,128,127,127,127,127,127,126,127,127,128,127,127,127,128,129,129,129,128,128,128,127,127,128,128,128,130,129,128,128,128,130,130,129,129,130,129,129,129,129,129,128,129,129,129,129,129,128,128,128,128,127,127,128,128,128,129,128,128,127,127,127,127,127,127,127,127,126,126,126, 125,126,126,126,124,124,125,126,126,125,124,125,124,124,123,122,123,124,124,124,124,124,124,124,123,123,123,123,125,125,125,125,125,125,124,124,125,125,125,126,126,126,127,127,126,126,127,127,128,129,128,127,127,128,129,129,129,129,129,130,130,129,129,129,130,130,131,130,131,131,130,130,131,132,131,131,131,131,131,132,132,132,132,132,132,132,132,131,131,131,131,131,133,132,131,131,131,130,131,130, 130,129,129,129,129,130,130,129,129,128,128,128,129,129,128,128,127,127,127,128,128,128,128,127,126,126,127,127,127,128,128,128,128,128,127,127,126,126,127,127,127,127,128,127,127,127,128,128,127,127,127,127,127,126,127,128,128,128,128,128,128,127,127,127,127,127,127,127,127,126,128,127,127,127,127,128,128,127,128,129,129,128,128,129,128,128,129,129,129,130,130,130,131,131,131,132,132,132,131,131, 132,132,133,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,131,131,130,130,130,130,129,129,129,129,129,128,127,128,128,127,126,126,126,125,125,125,125,125,124,124,123,123,123,122,122,122,122,123,122,121,121,121,121,121,121,121,121,120,120,119,120,120,120,120,120,120,121,121,121,121,120,119,120,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,122,122,122, 122,122,122,122,123,123,122,122,123,123,123,123,123,123,124,123,123,123,123,123,124,124,124,124,123,123,123,124,124,125,125,125,125,125,125,125,127,126,126,127,127,127,127,127,127,127,128,128,129,130,129,130,129,129,129,129,130,131,131,131,131,131,132,132,132,132,132,132,132,132,132,132,133,133,133,133,133,132,132,133,133,133,133,133,133,133,133,132,132,132,132,132,131,131,131,132,132,132,132,131, 131,131,131,131,130,130,130,131,131,130,130,130,130,130,130,130,130,130,130,130,131,131,131,131,131,131,131,131,132,132,132,132,132,132,133,132,132,132,132,133,133,134,134,134,134,134,134,134,134,134,135,134,134,134,134,134,135,136,135,134,134,135,134,134,135,135,135,134,134,134,134,134,134,134,134,134,134,133,133,133,133,132,132,132,132,132,132,132,131,131,131,131,131,131,130,130,130,130,129,129, 129,129,129,128,127,127,127,127,127,127,126,126,126,126,126,125,125,125,126,126,125,125,125,125,125,125,124,124,124,124,124,124,125,125,124,124,125,124,124,124,124,125,124,124,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,124,124,125,125,125,125,125,125,125,125,125,125,125,125,124,124,124,124,125,125,124,124,124,124,125,125,124,124,124,124,123, 123,123,124,124,123,123,123,123,123,123,123,123,123,123,123,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,123,123,123,123,123,123,123,123,123,123,124,124,124,123,123,124,124,125,125,125,125,125,126,126,125,125,126,126,126,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129, 129,129,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,127,128,127,127,127,127,127,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,129,129,128,128,128,128,128,128,129,129,129,129, 129,129,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,130,130,130,129,129,129,129,129,130,130,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, 127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,130,130,130,130,130,130,130,130,130,130,130,130,130,130,131,131,131,131,131,131,131,131,131,131,131,131,131,130,131,130,130,130,130,130,130,130,130,129,129,129, 129,129,129,129,129,129,129,128,128,128,128,128,128,127,127,127,128,127,127,127,127,127,127,127,126,127,127,127,127,127,126,126,126,126,126,126,126,126,126,127,127,127,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,127,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,127,127,127,127,127,127,127,127,127, 127,127,127,127,127,127,127,127,127,127,127,127,128,128,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,130,130,130,129,129,129,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130, 131,131,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,126,126,127,127,127,127,127, 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,127,127,127,127,127,128,128,127,127,127,127,127,128,127,127,127,127,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,130,130, 130,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,127,127,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127, 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, 127,127,127,127,128,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127, 127,127,127,127,127,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129, 129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,127,127,127,127,127,127,127,128,128,127,127,127,127,127,128,128,128,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128 }; const uint8_t SN[] PROGMEM = { 130,143,152,140,112,95,101,101,97,106,136,152,96,80,128,137,114,67,93,85,80,95,113,178,138,72,128,206,179,162,141,194,171,165,231,185,200,199,199,202,192,176,172,182,139,173,193,156,159,163,132,124,142,99,146,110,109,180,80,89,218,88,22,155,225,170,100,74,138,101,27,127,166,131,169,155,67,100,127,116,55,97,135,105,99,138,124,112,143,107,66,48,63,89,98,101, 117,106,102,119,140,130,127,150,118,125,178,135,95,136,108,170,213,153,121,131,166,189,134,60,89,129,115,85,90,113,193,197,107,46,93,171,216,201,184,156,156,179,156,157,152,148,157,145,121,128,122,128,117,118,126,142,116,105,137,102,94,153,157,106,151,161,77,93,129,115,116,75,74,145,177,167,128,126,130,61,51,121,170,135,98,115,111,95,77,108,140,149,136,111,79,104,134,134,130,121, 106,109,125,96,99,135,146,137,134,142,155,133,119,158,172,138,146,138,117,150,196,160,117,143,131,113,142,171,158,115,105,131,130,120,82,109,158,146,136,127,128,131,128,131,141,146,134,111,117,107,102,103,94,125,133,100,102,119,113,105,94,110,115,91,99,125,115,96,123,143,126,108,89,111,118,111,123,125,123,116,143,154,144,147,136,115,96,119,160,172,168,130,105,113,111,150,156,127,145,139, 120,105,110,136,138,143,149,113,140,126,110,141,157,135,114,156,152,113,125,136,103,117,154,133,100,118,118,101,112,121,112,104,99,112,114,126,144,144,123,90,80,126,165,144,137,162,139,105,106,124,139,158,146,129,120,104,152,148,113,107,116,116,94,84,121,149,125,121,133,105,111,123,132,126,136,150,126,118,107,127,143,151,147,134,112,118,127,161,161,143,140,134,126,117,101,126,154,125,132,152, 147,126,118,125,144,127,123,139,125,118,141,120,114,110,117,140,129,122,117,118,127,141,116,117,151,157,141,116,79,89,128,136,120,105,114,135,122,100,105,112,128,130,126,138,144,138,115,117,118,103,118,132,155,165,155,131,119,133,128,120,118,143,159,119,114,143,141,142,136,147,128,117,135,119,118,116,133,150,140,124,145,134,124,121,135,155,134,116,113,116,128,127,113,133,146,133,91,104,144,123, 114,134,128,111,104,124,132,142,143,116,123,135,139,123,111,124,131,118,127,134,126,114,134,122,115,122,130,123,102,144,163,132,127,127,102,130,147,141,119,138,142,107,119,121,110,137,144,128,130,152,125,102,158,154,140,140,127,114,107,127,124,127,140,137,106,127,148,114,102,123,137,119,146,153,140,128,135,144,122,130,153,120,115,122,119,151,145,117,114,102,111,133,134,119,126,138,102,110,117,120, 140,115,106,120,117,119,130,147,119,110,147,127,107,137,131,135,144,137,123,100,127,142,138,114,117,130,133,131,118,130,153,141,119,133,127,144,153,127,128,124,131,135,142,131,127,142,145,138,115,121,139,116,106,138,131,133,124,106,143,151,119,123,127,132,132,122,130,111,117,135,126,125,126,132,119,126,138,123,127,127,121,132,133,148,149,120,117,122,122,123,125,117,115,134,141,117,119,120,123,130, 122,140,133,127,136,118,109,116,133,115,108,148,156,130,117,132,133,124,103,118,149,144,137,143,125,120,116,120,120,117,124,131,122,129,122,125,150,131,135,147,134,136,122,107,127,140,156,147,140,136,119,124,130,130,138,132,141,134,135,133,97,111,131,122,119,139,136,113,128,147,118,104,119,112,128,136,141,125,128,143,116,105,124,131,133,133,123,130,147,137,132,128,127,125,108,132,153,134,119,120, 95,122,145,115,114,143,121,99,122,154,141,111,132,134,93,123,142,131,152,151,130,116,120,150,150,122,135,141,129,112,115,135,118,140,162,121,112,123,125,122,109,115,133,131,149,146,118,127,134,144,141,115,119,134,123,129,131,117,131,146,126,127,130,129,131,110,103,120,139,134,109,114,135,123,117,131,124,106,133,162,146,118,122,129,125,129,135,145,115,115,152,116,112,123,126,145,141,132,137,138, 134,125,115,107,118,158,153,116,118,112,106,146,141,121,122,125,139,128,121,134,136,120,127,138,125,118,149,138,136,136,130,126,124,130,146,155,128,131,137,119,133,151,117,112,127,128,123,131,111,120,118,106,120,124,130,108,116,121,132,123,124,134,122,125,118,121,127,122,149,143,105,116,119,125,142,145,128,131,123,117,136,135,129,136,133,141,123,119,136,147,140,123,142,126,121,117,103,146,153,137, 133,134,130,139,150,137,113,118,134,133,122,129,151,132,110,124,140,112,108,122,132,135,142,131,115,128,139,135,126,127,125,121,132,128,116,118,142,142,119,113,127,133,121,119,138,146,142,117,103,121,132,138,114,119,117,112,98,114,129,113,129,115,120,122,113,131,139,148,148,139,129,119,119,123,130,144,151,142,132,139,134,127,136,129,153,147,131,130,133,129,127,118,131,137,130,153,131,97,122,130, 137,157,140,123,117,134,127,125,131,127,132,141,143,125,98,117,123,124,132,132,126,116,113,93,104,135,133,117,125,119,122,132,121,117,129,129,127,138,138,132,124,124,117,128,126,124,134,141,153,151,119,121,137,139,135,123,119,121,127,128,125,114,130,135,113,111,137,117,124,148,145,132,130,146,131,117,137,144,138,117,132,143,140,144,141,117,118,128,118,119,132,149,136,128,131,124,109,128,131,132, 129,113,121,120,132,147,125,106,115,144,145,137,140,136,123,108,124,130,114,127,127,124,127,119,118,114,105,120,128,119,118,123,131,129,117,117,116,118,118,129,146,135,131,122,133,143,138,139,149,145,133,129,139,134,128,132,136,136,125,131,141,122,116,140,142,129,111,119,136,132,120,125,129,136,127,120,146,150,119,118,135,137,138,137,131,133,137,126,117,129,135,135,135,115,94,101,129,136,126,129, 134,120,112,105,108,119,134,139,125,123,139,132,114,119,127,138,152,139,112,121,133,131,137,141,129,122,123,121,116,136,156,125,105,123,135,135,127,128,127,119,122,128,124,123,129,133,133,129,127,134,146,135,118,122,144,140,131,127,136,140,133,136,131,119,122,128,127,133,131,116,120,124,126,133,119,114,129,128,127,125,133,149,123,113,123,130,124,140,142,124,118,124,128,133,128,130,133,138,134,119, 120,133,134,119,127,136,128,109,118,123,121,131,135,130,116,116,122,126,136,134,140,132,118,116,118,139,143,139,139,129,131,125,129,131,125,139,140,125,107,113,118,121,138,148,141,125,118,124,137,149,135,119,118,133,143,127,123,124,135,135,124,122,134,134,135,140,128,120,118,115,107,127,127,121,118,126,129,129,128,117,119,124,132,131,126,127,141,136,125,124,131,139,140,138,137,119,124,139,138,124, 113,138,145,135,120,107,113,121,134,121,118,127,135,139,130,129,128,126,114,124,131,129,133,130,129,137,130,134,123,116,130,130,137,131,121,124,123,127,139,134,125,120,129,132,128,126,134,131,125,139,136,124,125,126,126,148,144,130,133,129,134,130,119,128,143,139,126,116,112,120,122,118,124,125,127,125,126,119,111,125,132,126,127,130,119,117,119,123,124,134,139,132,132,126,114,128,142,136,134,130, 131,134,129,127,132,129,124,134,132,130,139,136,125,123,124,124,122,122,131,138,129,119,126,131,128,135,138,134,134,121,117,132,141,141,130,125,128,122,127,131,126,118,123,130,123,133,147,135,117,114,116,131,135,125,120,130,144,131,120,113,131,144,131,122,114,125,131,126,119,123,123,131,142,130,118,113,118,130,133,132,136,130,119,119,127,124,128,141,136,140,134,124,118,126,130,129,133,141,136,116, 111,128,140,130,130,132,129,118,136,147,132,125,119,127,132,126,129,135,127,126,123,136,138,117,122,133,126,124,126,129,140,131,114,113,129,133,121,120,127,133,144,141,116,115,124,129,133,129,128,123,135,127,121,119,109,119,125,132,146,129,119,122,124,123,124,140,127,118,126,134,127,124,128,136,139,137,133,135,128,125,131,128,133,136,117,128,141,137,137,134,128,127,134,139,131,123,128,131,134,127, 121,118,120,125,137,134,123,126,127,123,127,122,124,126,131,129,117,115,123,136,129,125,125,122,125,125,129,128,124,121,123,129,139,140,127,119,123,133,133,131,129,127,129,129,121,128,136,127,118,123,129,134,138,137,126,123,124,136,136,122,120,133,142,130,125,125,128,134,135,136,125,121,129,143,135,123,129,126,121,121,125,138,142,129,133,129,128,124,123,128,126,124,137,144,126,118,117,117,128,141, 136,126,118,118,128,128,125,123,125,130,128,121,121,125,123,123,133,139,138,131,119,122,131,128,122,123,131,128,124,124,130,132,115,121,130,130,133,134,133,120,118,120,124,142,148,140,127,123,123,125,134,131,128,137,144,135,124,135,138,127,126,131,127,129,136,128,123,127,134,126,121,127,129,122,121,121,128,131,120,123,132,130,126,133,128,118,124,134,128,125,129,135,137,134,124,122,125,122,123,133, 139,133,128,109,103,120,128,126,135,133,120,127,124,115,117,120,130,143,137,123,123,126,126,123,137,140,130,131,138,127,126,138,137,130,131,140,135,128,134,133,127,134,134,129,128,127,130,136,126,121,125,137,135,108,100,125,139,137,136,127,124,118,121,134,137,128,124,128,125,127,133,137,126,123,127,127,133,129,128,121,120,115,121,135,128,123,127,131,122,127,127,123,135,137,128,122,124,128,128,132, 137,137,129,124,116,124,128,123,125,125,127,129,131,125,129,144,139,121,120,130,139,131,125,130,136,133,126,130,137,132,123,129,137,132,124,126,132,136,132,128,135,132,117,111,118,127,137,131,127,131,123,116,115,123,130,128,132,127,113,120,134,132,121,124,128,131,135,127,125,126,129,134,134,131,129,124,121,126,131,136,134,124,124,125,128,130,129,126,122,123,134,143,133,122,124,133,136,127,122,128, 133,136,132,126,125,137,134,126,127,125,126,127,136,136,118,122,129,124,119,127,129,119,125,134,131,127,129,129,125,123,130,135,129,131,131,133,133,121,119,128,131,123,126,132,135,126,117,123,129,126,132,131,119,124,130,126,123,134,135,127,128,126,125,124,128,124,123,127,129,134,136,133,123,128,136,130,122,125,133,134,130,131,132,130,127,123,123,129,136,137,131,124,122,136,136,121,125,127,126,129, 124,123,127,128,132,134,120,113,123,133,143,136,130,123,119,122,131,136,138,137,132,125,118,123,125,126,130,129,121,124,133,131,130,123,114,120,126,138,135,125,134,132,121,117,126,137,135,132,130,123,130,130,120,122,125,129,127,127,128,127,127,125,129,134,134,128,130,132,125,125,132,129,130,136,128,121,123,129,130,132,128,121,118,129,141,134,126,128,129,139,136,123,121,125,130,132,131,122,122,131, 134,131,126,120,122,129,129,129,126,126,123,123,128,125,123,126,130,131,136,131,125,124,128,133,130,128,132,137,132,127,132,132,123,116,117,123,134,133,134,130,126,130,126,126,122,123,131,138,132,131,130,126,121,130,143,139,127,117,121,133,134,125,123,131,131,122,120,123,126,129,128,127,125,130,138,130,125,124,126,128,128,131,130,132,127,123,122,124,131,130,121,120,128,131,132,138,134,118,115,122, 127,128,131,132,134,134,126,118,122,138,135,123,124,130,132,130,129,131,132,132,129,125,121,125,130,133,136,126,129,132,129,127,125,125,126,128,132,133,129,123,118,126,128,125,127,134,135,136,129,126,132,121,122,132,133,131,134,131,127,123,119,128,129,122,125,128,124,126,123,118,126,133,132,131,125,120,114,125,139,135,129,126,136,141,126,121,130,137,137,128,124,128,134,130,127,137,136,126,129,128, 121,127,127,127,133,128,121,121,130,130,123,126,129,130,128,119,121,132,134,130,129,122,116,127,135,136,130,128,125,126,131,130,125,124,129,130,136,132,124,123,126,131,129,128,133,129,121,122,128,129,124,125,128,127,128,123,128,126,124,130,123,124,137,139,132,127,127,129,127,129,138,130,127,133,133,131,133,132,128,132,128,127,128,122,122,129,131,131,125,124,130,129,126,127,130,130,130,127,123,126, 130,131,129,132,131,122,117,118,124,127,133,131,128,126,118,117,125,140,141,129,121,123,124,123,127,134,133,128,128,126,128,134,136,129,130,131,130,127,129,128,121,129,136,135,132,125,120,117,125,130,127,127,134,133,126,128,126,123,123,133,137,131,123,125,130,132,134,130,127,131,134,133,130,126,129,127,125,128,128,129,128,127,130,131,126,122,124,127,131,132,123,123,125,124,127,134,131,128,125,124, 127,128,128,126,127,124,126,134,134,126,120,118,127,133,134,130,129,127,122,126,127,127,127,125,125,133,137,134,128,123,125,129,127,127,133,136,131,124,124,131,134,130,124,132,140,131,126,127,131,131,126,127,130,131,127,123,129,129,125,128,129,131,131,122,116,123,136,138,126,119,124,131,133,133,135,133,123,121,126,125,123,131,135,127,122,124,126,123,123,130,131,127,120,125,131,128,126,126,135,136, 129,130,129,130,129,130,135,127,130,134,129,122,120,129,133,129,128,124,123,128,128,124,124,127,126,127,134,131,118,122,133,136,132,123,132,138,134,129,125,131,136,134,127,122,125,129,129,132,135,129,128,129,130,127,119,124,131,134,131,121,120,122,124,126,126,127,128,131,124,119,125,130,133,133,127,123,127,127,128,129,127,124,128,133,134,131,128,125,129,135,130,125,125,126,126,128,129,132,129,128, 129,127,126,128,129,126,127,136,133,120,122,123,125,139,144,130,122,127,127,126,128,131,127,127,132,128,127,126,128,132,125,119,121,127,131,134,129,122,124,127,132,131,126,123,127,129,127,127,126,128,127,119,123,130,131,134,129,121,128,137,136,134,132,129,128,129,126,127,130,134,135,131,126,128,126,120,122,129,129,129,130,134,133,131,125,123,125,127,125,125,131,129,134,134,125,118,125,132,130,133, 130,124,119,120,125,130,133,131,128,122,120,127,133,127,125,128,128,129,133,134,133,131,127,125,127,131,131,127,124,130,132,128,125,127,133,131,123,122,128,135,131,124,125,132,136,126,125,129,131,129,126,127,127,127,122,129,133,126,122,126,129,130,130,128,130,126,125,130,137,133,124,119,124,134,132,130,125,124,130,132,125,125,129,124,122,126,129,131,132,130,126,124,127,133,133,130,132,132,126,123, 122,124,128,130,129,129,130,123,122,126,128,130,131,125,123,126,130,136,132,127,124,125,127,131,133,133,132,130,126,125,126,130,133,129,129,129,125,130,136,132,124,122,124,130,134,127,125,130,130,127,125,128,130,131,127,125,127,126,129,127,127,126,128,129,128,123,121,123,127,129,127,125,127,128,127,128,125,127,129,127,126,128,129,129,131,130,127,124,123,128,132,131,127,131,131,129,126,124,129,136, 139,132,127,127,127,129,131,133,134,130,126,124,129,130,126,126,130,132,126,120,124,128,129,133,130,122,122,126,130,129,128,133,131,128,126,123,121,124,129,134,131,126,126,126,127,126,127,129,126,126,128,129,125,125,130,132,130,128,126,123,127,127,127,130,128,126,127,129,132,131,131,129,126,123,125,131,132,130,130,130,128,128,126,125,124,130,135,126,120,125,131,130,129,130,128,125,126,130,130,127, 125,128,137,138,130,124,124,129,136,133,128,127,127,127,126,129,134,133,125,123,126,128,129,129,123,124,132,131,126,123,124,122,121,127,129,129,127,126,128,132,131,129,126,127,127,128,132,129,126,128,128,125,127,127,127,131,129,125,124,126,128,127,131,133,132,127,124,127,128,129,131,133,133,128,127,127,128,134,132,130,127,126,129,131,129,131,133,131,129,127,127,127,125,126,125,126,126,126,124,122, 127,126,126,125,126,128,129,129,127,128,129,129,134,131,124,122,127,136,132,125,126,131,130,129,127,128,129,130,130,129,126,128,130,129,128,124,123,126,126,130,128,126,127,129,130,130,135,132,130,129,125,120,124,132,131,129,126,127,130,125,121,122,127,135,138,131,128,130,127,123,126,129,132,132,131,131,127,126,126,128,130,132,130,125,121,122,126,130,131,130,129,129,124,125,127,128,127,126,129,129, 127,124,126,131,131,127,127,128,127,127,129,129,130,131,132,131,127,126,129,131,129,128,125,124,126,129,130,127,125,129,129,128,129,130,129,128,131,130,125,123,128,132,134,130,126,128,129,126,124,125,129,132,130,125,128,131,129,127,127,125,123,129,130,124,124,128,128,126,127,127,129,132,130,126,123,125,129,131,131,131,129,125,124,126,129,130,130,130,128,127,126,129,131,128,128,127,127,130,130,128, 125,126,131,130,124,123,131,133,127,127,130,129,128,127,128,130,129,128,128,132,131,126,127,126,131,135,130,125,124,128,129,126,126,128,127,127,125,124,126,130,130,128,129,129,128,126,126,126,129,132,129,127,128,131,130,124,127,131,130,125,128,129,127,127,128,126,127,131,130,127,125,126,128,130,130,131,129,128,128,127,126,124,126,130,131,130,128,127,128,128,131,131,128,127,128,129,131,132,128,126, 127,129,127,126,128,130,129,129,128,125,125,126,131,132,130,128,124,125,129,131,130,128,127,128,129,128,125,123,124,129,133,128,125,125,125,129,130,128,126,128,130,130,129,126,125,127,128,129,128,127,127,126,128,131,130,128,127,128,132,131,127,124,125,127,128,129,129,129,129,126,126,130,130,128,132,132,130,130,128,129,128,127,129,130,128,128,128,126,125,126,130,129,128,129,125,123,128,129,131,130, 126,126,127,131,132,127,126,128,127,130,131,131,129,125,124,126,131,131,129,128,128,128,127,127,128,130,129,127,128,132,130,124,124,128,128,128,128,129,132,129,125,123,127,130,131,132,130,126,125,126,127,127,131,129,126,127,128,127,129,130,127,127,129,126,127,128,127,128,128,131,132,130,126,124,126,128,129,128,130,132,130,125,125,128,130,130,129,128,127,128,129,131,131,129,129,127,128,128,129,128, 127,127,127,129,131,128,126,126,127,129,129,127,127,127,128,127,126,126,129,129,127,128,127,127,127,128,129,127,126,126,128,130,131,129,128,128,129,130,128,127,127,129,127,128,131,127,125,126,128,128,130,129,127,127,129,131,128,126,128,129,129,127,126,129,131,128,127,128,128,132,131,129,126,126,130,131,130,130,128,126,127,128,128,128,128,129,129,128,126,128,129,126,123,126,129,128,128,129,128,127, 128,131,132,131,128,128,128,126,126,128,128,129,128,128,128,128,131,130,125,125,130,131,130,128,127,129,129,126,125,125,125,128,132,130,125,125,127,131,128,125,127,131,132,128,126,127,126,127,130,129,128,129,128,129,131,128,125,127,128,128,130,129,128,126,127,129,131,128,126,126,127,129,131,129,127,127,128,129,126,127,129,129,129,129,130,130,132,128,126,126,126,126,129,129,127,128,129,129,129,127, 124,126,128,132,132,127,126,128,127,127,128,127,127,131,130,128,127,127,126,125,126,128,129,130,128,127,126,127,128,129,127,126,128,129,130,128,127,129,129,128,128,128,130,130,129,128,126,128,130,130,131,128,127,128,128,127,127,127,128,130,130,127,128,128,128,128,130,131,131,130,128,128,129,129,127,127,129,130,130,128,127,127,128,128,128,128,127,128,130,127,125,126,128,130,127,125,126,128,128,127, 127,128,127,126,127,128,129,128,129,131,129,128,127,127,128,130,130,129,128,127,126,126,128,130,129,127,127,128,128,127,127,129,131,129,127,128,128,128,126,129,131,129,128,128,129,130,130,129,128,126,127,129,131,130,128,128,127,126,126,128,128,129,131,129,125,126,127,128,129,129,129,129,128,127,128,130,130,128,128,129,128,126,126,128,129,129,129,128,127,127,126,127,129,129,128,128,130,128,127,127, 127,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,128,128,128,128,128,128,128,129,129,128,127,127,128,129,129,128 }; const uint8_t HH[] PROGMEM = { 128,131,142,131,123,144,109,153,108,135,139,101,152,130,111,116,151,93,93,187,58,159,87,135,133,108,151,107,123,132,108,138,122,124,132,122,185,104,155,64,169,159,86,112,155,107,78,178,51,92,122,81,135,147,150,103,143,77,243,116,136,187,130,145,141,146,97,223,135,50,251,116,126,72,211,129,139,151,91,182,54,183,1,240,60,107,145,140,134,98,107,124,133,120,142,130, 153,97,183,43,183,127,77,233,61,116,212,27,146,128,125,94,120,124,71,95,116,88,191,99,200,41,127,236,66,208,59,249,85,181,224,85,194,147,149,127,205,99,126,153,163,109,155,133,156,85,170,105,117,69,144,179,59,199,23,212,39,175,142,86,89,160,112,65,171,69,154,138,140,110,145,154,148,118,142,72,180,104,137,138,130,157,157,118,143,197,109,147,142,156,54,162,59,189,49,142, 103,148,133,60,153,84,153,105,105,146,150,90,163,107,122,171,98,132,147,106,133,124,84,193,138,107,166,142,75,169,116,74,155,86,120,96,125,106,81,130,146,107,80,204,132,88,171,122,138,160,91,172,75,145,171,91,152,147,94,80,213,72,164,116,97,140,126,82,125,132,75,144,86,117,145,78,122,155,84,156,114,136,146,104,155,126,199,101,131,142,112,179,134,128,118,151,135,141,111,165, 132,135,142,155,98,115,150,113,138,111,143,81,121,142,37,177,90,97,131,142,103,105,191,92,152,127,136,130,122,105,186,115,132,135,127,150,105,134,121,109,136,124,159,87,139,116,110,147,103,149,126,109,137,132,147,129,145,152,107,145,163,106,141,138,113,140,115,141,101,151,126,116,146,131,137,114,118,154,69,130,111,109,144,81,175,82,152,124,130,144,140,148,94,176,124,114,161,152,133,131, 160,111,128,148,96,140,107,137,102,127,152,136,109,140,147,132,125,131,111,150,94,141,119,118,154,114,133,122,141,108,118,153,103,115,128,113,121,101,153,101,166,114,138,127,136,134,109,145,133,148,103,172,134,132,139,153,131,126,126,131,97,132,130,89,137,136,129,91,171,105,124,137,137,122,146,143,137,148,112,149,122,130,140,124,121,130,133,113,141,133,110,138,123,116,120,113,139,108,123,133, 120,116,128,135,132,127,135,128,134,146,135,120,142,142,126,155,130,139,127,134,142,131,118,129,136,115,126,130,106,127,134,118,117,145,107,137,117,123,143,115,145,123,141,110,143,125,129,132,125,125,129,134,119,123,126,130,103,127,132,125,119,124,130,127,132,131,120,130,144,121,128,143,129,121,125,157,115,125,135,118,139,125,127,123,125,131,109,127,117,128,104,131,137,112,133,119,134,121,128,121, 129,121,138,117,124,139,128,125,126,147,123,130,128,125,131,134,119,138,120,141,122,124,139,118,134,124,141,121,120,128,134,125,128,130,129,122,136,120,121,136,124,123,119,131,126,122,124,128,113,134,118,123,126,119,126,111,131,123,115,119,130,134,118,127,137,122,139,126,132,133,135,130,128,139,131,129,129,141,127,126,124,133,129,125,129,131,127,134,126,125,130,135,123,121,143,125,127,122,136,124, 123,131,119,128,121,122,116,127,125,120,120,129,126,114,130,128,120,128,120,128,129,125,131,125,138,134,127,131,143,131,127,134,132,134,124,132,134,133,131,129,132,126,138,126,123,135,125,125,124,132,126,117,126,132,125,126,128,125,126,133,123,125,133,130,124,127,132,128,122,128,129,127,128,123,125,124,129,123,125,130,130,121,132,132,131,129,128,138,126,133,131,127,130,130,126,127,136,125,125,123, 135,127,123,129,128,127,128,129,124,136,126,126,128,129,135,123,129,131,129,129,122,134,123,128,127,124,132,124,128,125,132,128,126,124,133,134,119,132,135,127,130,130,133,128,131,129,127,131,128,127,121,135,125,119,126,128,124,122,127,125,125,127,125,123,129,129,122,126,131,129,122,127,133,129,123,130,128,127,128,129,127,130,134,125,129,136,131,126,130,131,136,127,129,135,128,130,132,125,132,130, 124,128,131,130,123,125,132,130,121,125,129,123,125,124,127,125,127,121,124,126,124,119,124,130,124,124,120,131,125,125,128,129,130,129,128,129,129,133,126,128,136,132,127,130,133,130,130,129,132,131,130,128,129,129,133,126,130,132,131,127,128,133,128,129,125,132,127,126,127,124,129,125,123,122,130,126,118,125,125,128,122,124,127,127,125,125,127,129,129,125,126,132,130,124,129,133,129,127,128,129, 129,127,129,127,130,130,126,126,134,128,127,129,131,132,128,127,132,130,126,130,126,131,128,124,127,129,129,125,125,130,129,123,127,130,127,126,127,129,126,130,126,125,133,128,126,127,131,130,126,127,130,128,126,128,128,128,130,126,127,131,128,125,127,129,129,125,125,130,125,126,127,127,129,127,126,127,129,127,128,127,132,130,125,128,130,126,127,128,128,129,128,127,127,131,128,127,126,130,130,126, 129,131,128,130,130,131,131,129,129,131,130,130,128,127,133,128,125,128,129,127,125,128,128,126,125,127,127,127,127,125,124,130,128,125,127,127,129,125,128,130,127,127,128,127,127,129,127,126,130,129,126,128,130,128,128,128,132,129,129,130,129,130,130,129,129,132,130,128,129,130,130,128,127,130,127,126,128,127,129,128,126,128,129,128,126,127,128,128,125,126,128,127,126,128,127,126,127,126,126,127, 128,126,125,130,128,126,128,130,129,128,129,129,129,128,128,129,129,129,128,128,131,129,127,128,131,128,128,128,129,128,126,128,127,128,128,127,126,129,128,126,127,129,127,126,128,128,128,128,128,128,128,128,127,128,130,130,127,129,130,128,127,128,129,129,127,128,128,128,129,128,127,129,128,126,129,130,128,127,128,129,129,127,129,128,128,128,127,127,129,128,125,128,129,128,127,127,130,128,127,129, 130,129,128,128,129,129,129,128,129,130,128,128,128,130,128,128,128,130,129,128,128,128,130,128,128,128,129,129,126,129,129,128,128,128,128,128,128,128,128,128,128,128,126,129,127,126,128,128,128,126,128,128,128,128,128,128,129,128,128,128,129,129,128,129,130,128,128,128,130,129,128,129,129,129,130,129,129,130,129,128,129,129,129,128,128,130,129,128,128,129,128,128,128,128,129,129,127,128,130,128, 127,128,129,128,126,129,128 }; const uint8_t TO[] PROGMEM = { 132,125,137,125,129,122,127,131,125,131,123,145,122,137,116,137,124,149,108,125,151,128,128,130,125,105,139,119,141,138,120,132,103,141,118,141,141,125,120,111,143,137,132,105,122,128,139,117,115,116,138,134,117,112,132,143,136,139,136,139,136,111,103,108,126,142,137,140,134,118,107,112,115,123,119,121,122,129,138,141,138,140,133,128,123,125,127,140,109,148,123,129,137,124,138,122, 139,116,137,133,133,132,131,130,127,130,127,121,133,143,111,126,95,86,88,132,115,87,112,114,152,135,141,166,149,142,139,158,92,83,89,85,99,98,159,160,153,149,104,70,115,157,192,142,142,85,83,101,142,100,111,152,75,67,105,151,226,214,106,124,99,128,106,115,195,179,153,115,112,85,97,143,184,219,186,124,60,81,90,109,153,161,180,173,177,151,90,86,83,93,140,142,157,136,129,120, 165,183,135,139,127,144,149,154,134,116,129,148,98,94,111,112,119,131,156,152,148,129,147,124,94,142,113,112,113,133,173,153,129,137,115,155,194,154,123,128,108,158,146,145,126,40,16,76,138,126,133,130,157,121,70,94,122,152,97,197,238,177,130,70,134,91,68,175,217,184,189,151,72,13,22,147,156,115,73,61,137,171,231,190,84,109,80,96,125,151,178,189,133,117,116,135,157,189,154,96, 74,96,112,104,120,155,171,148,130,61,79,113,170,135,153,106,87,116,124,140,177,189,187,183,120,103,95,112,138,103,102,95,108,154,150,202,155,131,125,129,111,127,136,112,123,87,99,127,116,173,180,133,122,117,128,127,139,121,89,98,87,170,184,174,161,141,118,107,146,133,133,77,83,112,137,115,16,18,94,179,243,230,175,83,41,73,117,176,158,115,110,83,101,172,174,197,225,151,148,136, 104,101,56,36,101,120,106,121,92,126,199,184,98,108,86,84,144,175,164,122,100,59,99,128,175,189,173,197,123,87,53,60,92,79,116,207,227,215,129,11,51,121,136,167,100,148,170,208,156,49,67,111,168,152,101,114,127,118,106,97,103,115,179,185,168,128,112,154,150,125,58,55,122,112,138,105,133,134,152,207,192,135,117,114,87,100,114,149,148,129,113,167,148,103,117,156,140,120,137,119, 103,98,109,111,138,125,138,114,108,153,163,172,148,84,133,150,144,144,165,84,110,144,114,92,52,105,129,149,154,162,93,123,67,67,133,108,145,164,156,196,175,156,133,86,90,122,170,113,77,81,125,91,100,155,171,172,166,147,95,132,175,125,116,97,78,156,110,116,163,138,134,109,72,82,152,199,155,138,144,173,122,72,39,55,156,190,164,126,72,64,176,192,182,105,45,45,143,209,224,176, 71,48,90,142,141,153,107,65,115,178,171,135,168,169,143,100,117,100,69,125,188,180,156,121,69,99,118,121,105,155,101,143,142,111,164,121,136,142,71,96,125,160,155,141,110,114,166,131,126,107,122,140,164,180,114,104,98,78,104,139,138,128,76,104,158,126,174,164,158,112,99,109,121,141,121,161,136,94,82,120,182,174,158,100,135,114,111,115,81,102,143,148,178,126,91,88,123,153,102,107, 137,158,161,166,144,97,138,125,129,97,70,115,169,145,127,107,100,137,152,175,139,140,131,85,76,129,130,118,89,121,178,139,194,191,69,41,103,164,144,151,149,129,206,183,165,94,55,46,122,157,157,129,90,110,172,231,173,84,1,21,51,178,225,191,156,133,137,130,69,124,122,141,205,137,99,123,135,112,105,83,134,190,168,117,111,55,23,60,116,176,198,190,123,98,120,151,160,152,132,123, 100,106,76,130,160,131,192,158,154,171,148,137,142,145,143,117,60,67,65,119,170,175,130,138,99,119,112,136,89,131,173,183,174,114,126,126,155,141,122,116,61,24,79,119,238,212,134,128,104,61,114,126,201,201,182,126,61,56,26,46,138,161,161,164,148,112,60,96,139,214,191,194,132,23,57,185,217,191,137,81,86,96,131,98,147,134,116,94,106,133,85,87,168,171,162,150,143,156,139,138, 119,76,41,46,102,211,214,174,116,52,63,156,172,143,134,93,97,129,128,126,165,180,152,148,174,160,100,61,68,99,137,126,139,141,124,179,223,183,136,94,81,92,130,180,115,94,72,93,131,160,141,192,165,105,100,112,133,152,132,105,164,140,132,98,82,89,129,170,190,91,74,128,136,139,175,183,191,165,78,56,16,79,145,176,133,117,151,98,99,105,103,167,195,215,144,108,114,80,118,150, 139,110,69,77,96,168,180,160,158,154,88,81,94,115,111,153,162,144,129,94,134,124,131,100,110,146,157,146,146,146,158,132,90,58,89,132,182,185,157,169,114,125,111,56,90,136,145,143,133,107,79,156,205,162,157,136,111,87,71,57,104,118,147,147,147,149,178,172,132,72,128,211,141,123,62,73,112,99,85,115,182,226,199,163,94,83,37,80,172,179,156,61,81,122,178,136,144,151,172,173, 112,52,60,108,172,173,157,134,126,125,111,88,104,157,183,195,158,87,34,19,81,161,189,178,158,157,143,122,87,80,140,192,212,169,99,59,73,89,144,156,130,125,99,153,127,161,125,100,104,105,143,173,133,62,100,130,143,140,126,128,135,94,76,100,182,204,192,147,59,79,94,138,147,144,138,186,201,154,92,39,52,123,154,196,198,158,116,92,83,45,82,157,206,203,136,74,67,132,162,138, 113,96,117,130,137,146,148,153,131,115,116,151,134,71,102,143,156,148,124,91,102,118,161,167,147,124,141,121,88,128,113,126,140,149,188,166,113,140,140,128,115,87,63,66,138,142,146,127,123,135,122,139,162,176,120,116,161,155,118,97,106,129,129,130,92,104,124,143,174,111,77,64,123,176,155,137,142,135,115,73,40,139,206,196,193,124,77,100,91,77,95,123,156,183,139,129,128,132,124,118, 116,131,134,146,136,138,203,172,126,57,40,52,168,186,180,111,101,109,101,156,169,114,73,91,126,140,137,125,153,220,167,98,62,88,108,141,167,175,159,134,100,106,116,119,110,97,129,182,168,104,80,110,139,132,121,166,132,86,114,151,187,172,141,98,85,68,111,146,140,113,118,109,120,190,150,108,93,119,194,189,148,134,107,106,113,112,105,117,133,166,117,78,72,87,132,140,168,169,147,134, 123,120,100,93,115,169,193,174,160,164,141,84,26,26,110,189,170,156,137,108,126,134,152,108,110,121,134,155,153,109,74,86,128,208,191,137,74,16,65,189,224,187,127,88,100,76,111,114,130,167,182,167,133,133,123,96,113,129,138,133,125,143,140,125,79,58,113,162,175,159,110,127,167,166,169,120,43,29,88,157,200,155,115,139,157,151,104,108,127,127,148,153,146,107,73,74,108,139,125,148, 157,165,158,124,95,94,117,145,176,169,131,90,104,130,145,145,112,139,146,121,95,53,58,106,175,196,152,157,125,104,85,93,132,151,158,145,126,97,132,173,145,133,77,46,100,151,178,186,159,120,107,101,104,161,155,176,153,97,47,84,100,156,184,176,177,144,76,28,48,109,163,175,175,178,180,140,110,116,138,99,87,69,113,212,199,146,106,61,109,141,145,125,117,123,172,184,137,109,75,98, 133,135,167,170,120,118,131,130,101,78,74,102,159,187,202,136,98,82,86,115,167,180,147,92,57,108,164,188,189,143,79,97,107,123,105,116,146,170,167,126,113,97,120,135,145,176,168,131,119,107,78,88,122,116,130,154,157,146,179,130,92,99,99,95,106,146,159,164,100,95,149,139,77,96,148,194,180,167,144,81,52,50,136,192,177,156,125,86,76,127,152,136,121,138,193,182,135,57,46,104, 155,153,155,130,116,158,148,132,96,54,107,173,190,169,120,79,68,98,164,180,150,132,139,128,96,83,104,147,165,148,122,99,103,129,171,165,122,99,99,139,152,137,104,100,113,132,153,160,145,114,71,117,161,167,124,64,76,137,189,182,179,136,112,99,66,96,121,128,160,154,134,111,125,130,148,157,149,135,130,125,109,70,64,116,156,188,154,156,147,96,70,57,99,169,189,152,110,127,149,152, 126,101,93,131,179,169,148,97,73,93,109,126,154,170,149,120,105,107,112,101,118,150,168,129,132,164,151,132,99,90,117,121,152,144,129,109,83,124,136,173,128,121,134,119,114,132,177,152,105,97,106,142,173,120,75,53,145,182,167,134,77,71,118,162,150,133,114,142,180,166,119,76,73,100,136,140,158,186,160,126,62,59,113,140,142,145,128,127,130,148,168,159,155,145,102,89,61,78,132,151, 154,145,122,131,137,131,135,146,148,118,105,118,154,150,132,137,111,109,71,48,86,160,204,178,168,144,114,99,137,156,145,109,95,114,135,154,125,111,103,94,120,129,150,162,161,152,120,105,103,107,116,152,156,144,132,106,117,105,114,148,129,134,144,149,126,114,126,143,144,128,111,97,125,115,89,107,150,184,185,169,135,113,106,82,63,100,138,165,173,144,101,99,121,120,124,130,135,136,127,101, 112,144,180,159,123,101,132,155,127,93,80,105,152,169,142,99,49,98,179,183,163,147,116,104,109,125,132,119,113,133,143,159,145,129,113,102,107,115,124,129,142,151,159,154,131,119,142,139,123,103,91,100,139,140,137,140,128,112,117,136,150,150,125,99,111,110,124,148,149,149,135,100,93,110,136,151,135,139,138,115,97,111,152,171,168,145,102,75,91,107,121,147,139,147,141,134,149,156,144,110, 72,86,132,160,153,144,150,100,84,108,153,167,136,111,111,105,114,130,132,138,134,131,117,142,157,136,109,102,114,142,169,147,106,90,103,112,131,140,148,153,131,131,128,121,115,113,126,127,119,144,155,138,125,112,104,108,128,151,165,132,108,113,138,130,121,115,104,121,154,177,145,120,126,109,142,159,141,125,100,95,114,119,122,133,137,140,140,120,116,113,119,142,137,166,139,105,102,106,145,171, 155,131,100,92,112,144,157,135,114,124,134,127,123,119,128,126,129,133,128,117,117,127,134,141,117,118,133,132,123,136,137,150,152,120,110,94,98,128,157,158,132,103,113,140,138,136,137,121,107,95,126,156,169,149,118,106,106,127,142,145,118,113,125,107,104,126,135,136,133,121,138,130,124,121,139,157,143,141,140,119,91,88,123,157,173,155,97,78,90,119,138,158,153,134,125,116,137,141,135,121, 115,114,114,131,150,154,132,117,115,114,132,149,151,129,109,99,124,143,140,121,111,136,158,142,104,85,106,140,166,163,133,100,89,117,141,150,156,135,106,95,101,136,155,155,145,132,132,121,110,112,124,143,153,144,102,89,108,126,157,146,142,116,93,115,132,134,129,140,151,148,139,116,92,109,141,153,155,152,125,105,93,106,129,142,135,120,135,145,134,121,123,113,108,129,139,129,120,142,158,144, 114,103,117,131,140,115,106,128,159,164,144,116,108,110,119,120,133,151,134,110,111,122,140,142,142,144,136,118,103,113,118,124,122,125,146,149,124,114,123,135,149,141,123,99,109,139,161,171,137,104,96,111,124,151,141,127,102,104,129,147,156,121,97,115,146,159,148,114,105,115,125,124,131,135,144,144,129,119,117,116,131,133,131,123,118,126,138,140,124,119,117,133,147,146,127,102,92,105,139,161, 144,124,118,129,147,146,140,120,104,92,108,136,162,160,142,131,119,119,116,108,118,135,150,155,125,98,100,123,131,134,129,128,145,136,131,114,110,132,154,159,147,124,93,94,116,140,144,126,130,130,127,134,135,133,132,128,127,122,120,116,109,120,125,133,145,152,151,136,107,105,118,139,137,128,121,118,125,132,133,137,144,132,120,114,116,125,131,141,131,125,116,120,131,136,136,128,112,128,142,139, 131,101,103,122,133,138,136,134,133,115,123,132,145,140,124,128,129,118,102,106,131,154,155,136,117,109,120,140,130,119,113,123,140,143,135,130,129,132,122,118,119,125,133,140,142,130,120,120,127,128,123,118,118,126,144,141,126,117,125,145,149,130,109,108,112,120,140,146,139,135,128,120,123,132,130,129,123,121,126,129,143,139,118,115,122,133,137,136,126,122,121,124,131,133,144,139,128,114,99,118, 137,150,145,127,117,124,119,127,132,128,132,135,135,141,130,123,111,113,128,132,132,128,123,129,134,123,124,132,140,141,127,111,118,119,135,142,138,138,124,115,114,118,124,132,129,123,135,138,138,131,126,129,123,118,123,135,140,141,137,124,117,126,127,125,121,117,123,135,143,144,135,115,105,106,123,146,153,138,111,111,130,141,141,131,120,119,127,136,134,124,125,130,127,119,114,114,122,130,147,151, 133,122,124,135,131,127,120,114,115,121,143,138,128,130,133,125,112,118,129,135,138,131,123,128,128,125,130,141,137,132,122,116,120,127,131,129,134,135,129,126,116,113,124,136,139,136,131,122,119,128,131,130,125,128,130,128,129,124,125,128,123,127,131,129,128,133,139,135,126,121,121,117,115,126,142,143,130,122,127,128,131,129,125,124,120,125,133,137,140,130,116,123,131,130,126,122,119,126,136,139, 138,130,123,122,129,128,126,133,135,134,129,125,121,121,130,141,135,122,120,126,126,127,133,128,127,131,129,132,132,125,118,117,124,130,136,133,137,135,125,127,133,128,134,131,125,127,117,113,122,127,132,135,128,130,129,131,127,126,129,130,128,131,129,127,128,130,133,133,127,113,115,124,134,136,129,124,125,129,129,129,128,131,130,125,130,130,134,136,128,122,120,118,119,126,131,129,129,132,135,129, 123,124,129,136,134,129,122,120,121,127,131,134,131,130,129,131,125,126,130,124,122,124,124,132,140,134,130,125,130,127,132,134,130,123,118,118,125,130,133,137,138,133,120,115,123,136,129,124,126,130,131,131,130,125,126,127,130,135,134,124,120,123,129,127,126,126,129,126,124,128,138,140,129,121,118,123,127,131,129,128,129,127,126,128,134,138,132,118,115,118,128,137,137,131,127,127,126,127,132,132, 121,117,120,126,133,135,133,132,124,123,128,132,130,131,131,123,120,122,129,137,137,131,123,120,128,131,125,124,129,133,134,135,134,135,125,116,118,124,129,131,127,125,129,136,140,133,130,129,128,122,119,118,119,126,132,135,130,131,134,133,132,128,124,122,119,125,129,127,127,128,131,130,131,136,134,127,122,115,118,122,126,133,134,135,134,131,128,122,132,135,130,128,121,118,115,123,133,140,133,125, 122,123,130,138,138,134,126,123,121,122,123,131,134,131,129,128,128,128,127,127,127,126,123,127,136,133,127,123,124,127,128,126,131,133,135,135,126,120,118,123,126,132,134,138,138,129,122,115,124,132,134,129,122,123,128,129,128,128,130,131,137,133,128,122,126,129,129,131,128,124,121,123,131,132,133,131,126,128,130,131,128,125,124,125,127,130,127,124,128,131,132,130,126,128,128,130,131,129,128,127, 125,124,125,129,128,127,128,129,124,120,125,135,138,135,128,126,125,127,129,128,124,124,126,125,127,129,129,130,134,133,131,127,123,127,128,127,125,125,125,124,127,132,131,130,128,130,132,127,123,123,123,122,127,129,130,128,130,132,132,132,129,125,122,122,125,129,132,133,127,125,123,120,124,131,133,132,129,129,128,127,126,122,126,128,130,132,131,130,128,131,130,125,126,124,124,129,130,130,132,132, 131,127,125,126,128,130,131,129,131,130,125,125,125,127,130,129,126,126,129,134,132,128,126,130,135,133,127,121,120,124,128,131,130,127,128,129,131,130,128,127,126,125,129,131,131,129,128,125,126,128,128,127,126,130,129,127,128,128,131,130,131,132,127,125,130,132,128,123,121,124,130,133,129,126,127,129,131,132,127,127,130,129,125,125,128,127,128,129,131,132,130,130,131,130,128,125,124,126,128,131, 132,130,126,125,126,128,128,129,127,125,128,129,131,131,128,126,129,129,127,127,127,126,127,128,127,128,128,128,131,133,130,126,123,123,127,129,129,125,127,130,130,130,125,125,126,128,130,132,130,129,130,127,125,125,126,127,128,126,127,128,129,128,126,127,127,127,129,128,130,130,129,128,124,124,125,125,131,135,133,126,120,121,123,129,132,131,130,127,124,125,128,131,131,133,130,125,123,121,125,129, 133,132,128,125,126,131,133,128,127,128,129,128,127,126,127,127,127,129,131,129,130,130,128,127,127,130,130,126,124,126,128,131,131,127,124,125,128,129,130,129,128,125,126,129,130,130,126,125,128,131,130,127,127,128,130,130,127,124,125,128,131,132,129,127,127,127,128,128,130,130,131,131,127,126,124,126,129,130,128,126,125,130,132,129,126,126,128,131,133,131,128,126,129,131,132,129,127,125,122,123, 127,131,131,130,129,129,128,127,127,129,127,127,131,129,126,126,127,128,130,130,128,127,127,129,129,129,129,128,129,126,125,127,128,129,129,128,128,128,126,126,129,130,131,131,130,129,128,126,128,128,126,126,129,129,128,129,129,128,126,129,131,130,128,126,126,128,130,132,130,125,124,126,130,130,129,129,128,129,128,126,126,127,130,131,127,127,126,124,128,129,130,131,129,126,126,126,128,128,125,126, 128,132,133,130,126,123,125,130,133,132,128,124,123,125,129,130,130,130,128,127,126,128,127,127,127,130,131,127,125,126,127,127,128,128,127,128,128,129,130,128,128,126,127,128,128,127,126,127,130,131,128,126,126,130,130,129,127,125,125,127,129,130,128,126,128,130,131,130,126,126,126,126,128,129,128,129,128,127,128,129,129,129,130,129,127,127,129,128,126,126,128,129,128,128,128,129,128,126,126,127, 129,131,130,127,127,127,127,129,127,127,128,128,129,128,128,129,130,129,127,127,128,128,128,128,127,128,129,130,130,129,128,126,127,127,129,129,128,128,129,128,128,128,127,128,130,129,128,129,129,127,127,128,130,130,127,127,127,128,129,130,130,127,128,128,129,130,129,128,129,130,130,129,127,125,124,126,129,131,129,128,129,128,129,130,128,128,128,127,127,129,129,128,128,127,128,128,128,129,130,130, 129,129,127,126,127,127,127,128,128,128,129,129,127,126,127,127,129,128,128,129,128,128,128,129,128,128,127,127,128,129,129,127,127,127,127,127,128,129,130,129,128,129,128,127,126,127,129,129,128,125,126,128,129,129,127,128,128,128,128,128,129,128,127,127,127,128,128,129,128,125,125,126,128,129,130,128,128,127,127,127,127,129,128,127,128,127,126,127,126,128,128,128,128,128,129,129,127,126,126,127, 128,129,130,129,127,127,128,128,129,129,128,128,127,127,128,128,129,128,128,128,127,128,128,128,128,127,126,128,131,131,129,127,126,127,128,129,128,128,128,128,128,129,129,127,126,127,128,128,129,129,129,128,128,126,126,128,130,130,129,128,128,129,129,129,128,127,128,127,127,127,128,129,130,130,130,128,127,127,129,131,130,129,127,127,128,128,129,129,128,129,128,127,126,127,128,129,129,129,128,129, 128,128,129,129,129,127,127,127,128,128,129,129,128,128,127,128,127,128,129,130,130,129,127,127,128,129,128,128,128,129,128,128,129,128,127,129,129,128,129,129,128,128,127,126,128,129,129,129,128,127,127,128,129,129,129,129,129,129,128,127,126,127,127,128,129,128,127,126,127,127,127,129,130,129,128,128,128,129,128,127,127,127,128,129,130,129,127,127,126,127,127,128,129,129,128,127,128,128,128,127, 126,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,126,127,128,128,128,128,128,128,128,129,129,128,127,127,127,129,128,127,127,128,128,129,129,127,127,128,128,128,128,128,128,129,128,127,127,128,127,128,129,130,129,128,126,126,128,128,128,128,129,128,129,128,127,127,127,128,128,128,128,128,128,128,128,129,129,128,128,127,127,128,129,129,128,127,128,129,128,128,127,127,128,129, 129,128,127,128,129,130,129,128,128,128,127,126,127,128,128,128,128,128,128,128,128,129,129,129,129,129,129,128,126,125,127,129,130,130,129,128,128,127,127,128,129,129,129,128,127,128,128,127,128,128,128,128,128,128,129,129,128,128,128,129,129,128,129,129,129,128,127,126,128,130,130,129,129,128,127,128,128,128,129,128,128,129,129,128,128,128,129,129,128,127,126,127,128,129,129,129,128,129,129,128, 128,127,127,128,128,128,129,129,128,128,128,128,129,129,128,127,127,128,129,128,128,128,128,128,128,128,128,128,129,129,128,127,127,127,128,129,129,128,127,127,127,128,129,128,128,128,128,128,128,128,127,127,128,128,128,128,128,127,127,127,127,128,128,129,129,128,127,127,128,128,127,127,127,127,128,128,129,129,128,128,127,127,127,127,128,128,128,129,129,129,128,127,127,127,127,127,128,129,128,127, 127,128,129,129,128,127,127,127,128,128,128,128,128,128,128,127,127,127,127,128,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,128,128,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,128,128,128,128,129,128,128,128,128,128,128,128,128,128,128,129,129,129,128,128,128, 128,128,128,128,128,129,129,129,128,128,128,129,129,128,128,128,129,128,128,128,128,128,128,127,128,129,129,129,129,128,128,128,128,128,129,129,128,127,127,128,128,129,128,128,128,128,128,128,128,128,128,129,128,128,128,127,127,128,128,128,128,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,128,128,129,128,128,128,127,127,127,128,128,128,128,128,128,127,128,128,128,127,127, 127,128,128,128,128,128,128,127,128,128,128,128,127,127,127,128 }; const uint8_t CY[] PROGMEM = { 129,108,128,146,106,135,147,102,132,158,104,130,152,105,137,152,100,131,155,104,130,153,96,132,157,97,131,149,101,137,153,93,132,161,89,131,151,89,139,154,87,134,150,86,144,149,84,143,151,91,146,139,89,154,140,87,154,141,88,159,135,86,164,131,85,169,132,85,174,128,87,166,125,95,169,117,86,177,122,91,173,111,94,182,114,97,184,106,96,187,100,100,187,95,105,183, 98,118,176,81,118,177,95,130,161,85,132,153,103,136,143,103,134,143,114,136,136,109,126,141,128,130,139,118,115,152,131,111,147,108,104,172,115,113,174,87,118,183,82,137,161,55,151,163,74,176,128,67,182,123,104,184,85,107,165,98,148,143,99,138,131,137,134,130,119,99,152,126,127,164,85,137,156,95,179,111,80,166,86,153,164,75,166,101,118,193,85,145,113,73,174,114,140,138,86,145, 133,140,138,111,112,104,146,125,150,140,80,154,134,145,153,78,133,113,119,170,103,160,105,91,184,117,161,86,54,156,128,137,137,106,148,127,129,165,130,128,90,102,143,156,143,106,112,146,177,149,131,104,104,147,119,139,124,81,113,103,142,149,115,126,93,163,162,155,162,95,154,144,144,153,85,112,102,117,142,107,131,110,127,132,104,154,106,73,127,111,147,157,122,106,131,178,118,125,105,84, 151,127,142,149,157,184,130,165,156,152,161,82,89,114,154,151,95,121,101,131,150,124,126,104,102,85,139,172,130,124,83,94,145,126,79,47,84,135,160,156,112,137,179,192,199,125,115,130,120,183,121,125,138,88,153,169,189,127,65,95,123,179,153,101,97,116,181,158,95,56,77,145,76,68,85,108,155,125,148,146,141,135,103,129,104,129,143,124,165,184,192,169,121,146,118,118,121,105,108,120, 139,112,178,163,93,34,58,150,171,134,55,75,144,150,124,99,107,147,198,130,105,110,183,204,106,86,100,192,191,125,44,45,117,159,159,147,138,158,146,165,178,101,114,97,80,125,160,156,142,116,100,107,95,70,108,150,148,76,140,151,161,157,134,131,121,170,134,166,150,145,138,139,130,160,169,125,85,71,141,122,106,51,77,151,192,157,65,110,106,120,82,76,142,181,227,131,67,116,178,136, 99,58,104,196,150,83,104,144,177,190,125,109,149,150,130,98,130,135,164,181,155,160,137,116,112,103,89,133,110,131,152,162,135,107,111,64,91,75,133,114,107,180,138,137,107,109,95,108,95,91,100,130,153,115,150,138,201,217,157,124,124,127,157,142,141,134,138,142,115,120,104,107,88,68,93,97,152,134,101,117,119,169,142,143,110,133,163,146,134,125,148,183,192,162,133,148,152,128,113,70, 56,97,167,128,107,141,140,154,129,112,75,60,95,104,169,116,129,122,84,77,86,151,98,97,75,120,155,185,171,118,128,169,218,174,141,135,133,103,103,171,194,178,155,123,97,111,100,66,42,63,137,142,171,131,120,130,110,107,147,189,155,153,144,187,158,144,167,105,112,119,172,117,125,119,69,135,119,182,143,113,112,94,107,98,108,124,145,138,127,86,92,85,92,44,50,108,155,191,119,147, 134,112,105,81,129,148,190,166,161,177,185,137,45,33,93,150,123,119,127,161,168,116,102,81,161,146,105,131,163,199,160,148,122,190,218,151,115,136,173,126,108,98,129,177,185,110,88,113,121,145,118,87,112,205,187,162,134,111,65,87,115,136,188,172,158,136,144,101,109,99,39,55,98,156,126,138,134,35,91,102,151,159,116,94,98,120,73,118,123,129,128,166,186,163,157,57,2,43,81,132, 162,157,169,175,148,113,70,116,93,95,152,189,235,204,178,112,151,153,105,90,68,94,145,154,105,143,174,176,152,97,107,176,207,126,117,127,162,204,178,108,105,146,94,80,99,120,112,102,92,132,137,134,102,28,113,161,186,139,98,98,69,82,77,140,159,147,139,167,180,169,124,44,54,79,125,176,179,157,154,131,96,95,122,172,136,110,191,244,195,143,105,115,140,135,105,128,159,156,125,69, 81,98,75,73,82,146,188,184,108,88,102,110,138,136,108,98,181,189,146,132,102,124,142,166,168,175,155,81,76,82,174,153,140,122,136,168,139,143,94,37,11,72,95,158,176,123,136,124,115,78,80,93,102,171,154,168,159,149,127,100,93,128,189,234,174,123,119,116,170,117,94,67,171,132,110,173,149,132,95,75,62,162,173,155,158,171,184,158,155,72,112,136,129,165,131,124,98,159,136,91, 74,114,152,128,123,110,113,111,77,60,89,99,120,87,57,106,89,115,85,110,138,127,115,98,164,137,132,111,162,157,179,167,110,131,175,234,187,197,211,191,149,93,111,102,70,49,87,144,184,139,123,132,107,123,129,161,145,197,159,132,107,130,169,105,113,76,125,159,180,163,125,119,92,155,182,173,166,174,116,94,165,78,111,96,67,86,103,144,117,131,107,87,96,112,104,159,134,104,84,112, 142,133,151,89,129,121,114,99,89,128,114,142,99,147,166,117,88,72,96,81,104,90,121,105,127,94,131,198,165,143,76,100,156,191,185,163,146,141,115,118,149,172,132,45,79,116,158,169,140,149,140,188,151,156,162,157,130,86,137,196,227,180,158,163,201,217,173,109,102,133,122,181,187,136,107,107,112,99,133,139,144,141,123,102,109,99,69,73,52,81,91,71,50,52,51,36,43,27,30,76, 113,75,124,176,133,129,146,127,132,179,176,157,132,138,135,124,137,122,142,142,155,164,199,156,126,174,147,157,134,138,126,142,137,142,209,159,157,146,137,150,160,186,139,118,120,105,118,140,111,84,76,67,98,109,133,150,167,147,113,139,155,142,146,125,120,139,128,109,74,100,107,110,67,47,81,72,103,72,144,206,194,208,152,160,174,185,116,76,151,140,110,90,93,105,122,142,109,117,165,167, 160,173,172,184,157,152,143,172,173,165,146,101,113,110,160,148,135,132,158,179,158,153,153,178,126,107,102,108,146,123,127,108,115,109,91,82,81,87,88,70,60,65,61,52,23,31,70,61,14,28,70,112,141,99,93,137,168,140,125,164,179,159,98,92,104,159,154,142,198,183,204,175,163,141,136,114,103,174,192,188,101,90,125,171,180,126,147,153,148,139,162,174,162,158,117,146,168,171,89,60, 92,97,114,119,147,161,176,160,172,173,151,126,94,86,115,137,122,126,126,111,67,55,102,93,91,83,115,147,169,134,112,115,119,140,139,142,101,112,69,64,91,124,143,115,165,167,163,168,147,123,128,178,142,187,181,185,182,158,172,166,172,130,154,179,187,187,208,163,127,123,139,183,180,129,109,80,76,109,125,114,132,127,98,85,121,128,115,98,34,98,131,109,72,83,92,96,92,72,64,80, 113,82,74,98,135,137,116,101,138,163,129,95,102,102,96,90,87,99,141,130,128,109,133,130,129,141,144,197,156,125,91,117,121,105,107,96,132,119,129,143,126,124,123,157,138,142,139,136,147,132,142,166,164,137,120,111,140,157,141,129,126,119,146,156,148,172,162,140,100,124,150,128,127,123,161,181,157,153,148,126,130,121,117,126,128,148,111,102,109,93,71,51,63,46,59,64,77,128,158,157, 138,180,199,200,180,131,137,175,164,146,150,175,206,188,177,176,162,143,127,130,130,112,126,124,141,148,160,143,107,145,125,137,112,131,150,123,123,119,153,135,122,101,91,105,82,105,90,91,113,126,139,142,161,160,160,154,154,153,125,112,109,113,117,80,99,116,96,60,7,45,70,107,101,100,177,172,177,138,142,151,136,123,91,133,131,131,112,86,71,96,99,38,49,71,83,62,56,78,82,128, 145,168,173,141,148,127,126,148,161,152,124,150,155,182,208,206,189,128,132,136,123,110,96,102,103,131,153,164,190,157,137,159,211,194,156,133,107,117,144,153,131,115,93,76,87,115,121,113,151,182,184,178,159,171,168,182,117,97,111,120,171,134,130,163,173,142,110,119,117,135,135,118,139,184,179,153,155,159,154,149,141,112,115,81,81,90,107,131,156,167,157,134,128,128,99,87,56,62,45,46, 89,100,122,111,103,111,128,152,134,141,117,128,136,145,114,102,133,118,110,87,80,50,39,74,120,142,134,128,118,139,145,133,136,119,126,136,166,172,169,137,106,108,128,157,142,146,120,97,121,128,127,147,142,128,105,78,95,119,139,122,112,159,183,192,206,188,153,124,128,130,133,119,121,105,99,106,103,101,63,46,48,80,118,173,200,196,177,168,173,175,149,142,128,126,115,83,79,74,99,101, 118,149,130,139,142,120,129,153,152,124,149,172,174,150,136,126,109,88,91,114,154,182,159,193,185,171,166,135,130,97,76,76,118,137,120,118,126,140,177,187,135,165,186,166,141,133,138,137,140,113,144,143,136,118,89,128,123,158,160,147,170,180,178,155,155,132,128,102,109,102,91,70,52,72,67,81,118,121,113,125,105,98,109,99,83,72,81,116,115,85,65,55,65,37,63,121,119,85,84,113, 120,149,134,139,130,125,138,136,127,112,96,131,156,155,185,158,149,166,154,148,135,157,150,144,139,127,151,130,101,80,119,146,164,167,138,160,194,181,177,165,159,164,122,116,126,141,149,106,103,120,129,111,117,133,148,160,139,141,140,156,142,125,123,135,105,90,87,77,87,83,93,105,110,140,166,186,179,148,130,147,160,153,141,137,117,102,92,80,105,104,96,109,150,142,146,143,115,126,142,179, 171,191,165,133,117,113,150,148,162,123,160,205,198,201,148,123,114,129,93,100,129,121,110,98,116,132,152,140,116,110,122,105,76,90,112,124,88,103,131,101,55,32,46,41,69,76,110,152,163,158,154,187,187,159,140,121,149,172,148,113,117,128,120,116,116,124,107,109,90,68,79,97,119,131,163,185,182,152,126,127,108,95,107,138,155,134,150,176,166,147,126,116,129,143,112,97,113,152,141,129, 141,130,139,119,99,127,134,98,63,98,133,150,120,100,97,89,91,67,67,72,96,117,131,144,175,179,174,171,169,166,159,152,154,129,104,115,111,97,97,74,90,127,137,129,111,117,131,136,117,136,169,200,188,179,206,206,170,124,131,143,132,134,127,138,145,141,138,153,167,158,152,130,152,163,125,94,88,110,133,136,132,115,98,77,66,88,98,97,97,104,117,137,138,128,130,156,151,147,154,160, 169,142,148,164,194,191,170,180,181,169,134,104,85,94,106,108,130,145,154,135,132,143,151,149,133,134,145,141,127,153,163,146,135,119,129,116,76,35,31,59,87,95,91,111,116,114,108,120,135,114,103,95,94,106,108,91,92,106,110,111,86,91,90,72,60,81,102,115,139,141,153,152,148,130,113,117,110,120,121,124,137,145,146,125,120,104,89,67,76,99,95,99,105,121,130,143,162,187,177,135, 113,124,141,151,163,164,181,195,179,172,167,160,146,141,145,164,165,148,136,138,142,141,143,142,145,144,135,127,116,140,145,127,130,136,138,120,113,119,127,130,134,145,152,144,142,157,158,146,153,142,143,146,146,148,155,165,166,171,162,158,172,176,142,147,168,153,154,141,138,146,154,153,139,133,107,92,83,91,93,84,70,70,94,83,79,74,77,66,65,68,86,106,94,88,81,97,109,96,77,62, 76,89,74,72,93,108,95,85,107,143,148,122,113,109,104,119,124,143,167,187,171,154,166,168,155,134,139,146,149,140,132,141,154,161,143,133,128,123,124,126,117,118,116,95,105,124,135,135,134,128,106,95,111,135,164,179,173,183,190,186,181,158,134,139,145,144,153,158,150,118,101,111,122,135,126,106,107,94,83,89,98,97,116,124,120,141,123,114,121,113,124,131,143,157,159,159,147,155,170,162, 155,152,168,180,159,134,136,147,167,173,169,167,175,174,149,134,145,158,129,98,113,135,134,110,88,87,116,147,150,134,125,116,109,111,106,111,112,105,91,97,122,116,113,96,91,87,94,115,109,102,79,64,76,89,83,81,87,107,112,105,113,104,92,95,108,130,134,135,123,131,142,136,129,127,134,126,123,134,142,143,126,113,113,114,122,117,111,119,137,138,127,120,121,121,118,124,147,161,155,136, 151,162,177,172,152,151,151,154,161,157,148,146,136,117,133,158,147,147,141,143,140,129,134,133,134,132,128,124,119,117,113,115,124,140,158,154,145,138,143,141,131,125,134,138,141,137,118,111,94,108,119,128,153,169,183,178,165,146,116,112,112,118,127,137,143,137,120,103,108,120,125,140,145,128,115,107,107,109,122,129,144,159,153,132,115,101,81,77,81,90,124,143,133,114,98,93,89,84,83,98, 104,91,89,93,114,121,114,132,151,178,158,132,137,142,146,142,145,139,149,152,146,144,133,120,104,111,110,132,141,129,129,131,137,123,120,119,112,109,96,97,115,131,130,114,123,128,135,130,106,122,142,141,156,167,167,152,136,129,140,155,132,109,108,112,110,118,134,143,153,150,148,147,146,118,74,81,95,106,105,109,107,108,106,108,124,134,155,165,159,160,167,156,134,127,143,143,154,157,155,165, 159,141,139,157,178,177,175,190,197,190,160,129,116,119,123,140,147,133,122,104,96,103,111,107,105,110,113,113,111,107,105,89,92,111,131,126,99,88,87,106,120,134,122,118,132,136,137,117,73,47,45,54,66,99,114,101,95,119,149,159,159,151,158,161,165,176,183,162,135,130,142,140,133,114,98,96,114,131,139,143,140,144,149,159,151,126,102,82,90,94,93,107,110,110,119,128,135,155,155,150, 149,151,147,154,158,161,164,159,163,164,157,142,121,124,135,140,130,117,125,136,141,128,128,122,105,76,62,72,80,88,87,90,119,134,136,140,140,148,160,163,153,163,164,146,130,111,110,116,112,98,108,129,135,133,134,140,133,137,137,141,145,133,110,98,105,102,97,100,115,133,137,136,132,127,127,135,152,161,173,162,138,132,133,127,115,109,112,124,122,120,132,134,128,131,140,147,154,148,134,134, 135,131,126,127,141,145,137,129,129,139,145,145,153,163,170,172,167,166,151,140,123,105,118,120,109,91,94,109,107,101,97,108,116,105,82,84,101,99,92,80,79,85,93,92,95,109,135,149,141,138,137,143,154,161,163,159,148,142,129,113,107,105,101,105,109,107,105,111,117,119,120,118,117,125,121,118,129,126,118,102,110,125,120,119,117,120,134,132,134,141,162,168,180,194,187,190,176,149,135,135, 147,163,168,166,158,161,156,130,111,101,105,115,109,104,94,92,89,88,93,95,123,144,152,145,140,141,139,140,148,157,156,147,140,130,110,106,100,90,94,103,116,114,112,113,123,137,136,150,165,162,162,167,164,150,144,145,151,151,144,144,147,133,115,113,127,146,146,143,141,138,137,122,112,115,116,107,98,104,108,111,96,81,84,87,86,83,86,93,98,99,100,98,95,99,102,115,131,147,145,140, 151,144,140,145,154,152,144,143,142,144,130,116,117,124,120,108,109,112,117,121,128,133,131,132,128,128,129,141,144,146,147,148,146,132,130,134,145,148,150,147,148,162,159,149,149,167,183,175,160,152,149,141,134,131,131,129,128,127,120,116,103,99,97,99,108,113,106,102,107,113,111,103,100,103,107,125,131,128,124,122,118,115,116,118,123,117,112,108,115,122,126,122,120,126,127,125,117,123,135,141, 153,161,174,174,166,159,158,169,168,160,145,145,151,151,135,120,115,109,101,100,114,121,117,116,121,134,138,135,133,136,136,119,101,95,99,97,94,97,103,108,104,96,91,94,97,98,111,127,142,149,160,165,160,160,160,155,147,142,128,118,108,113,125,124,125,125,126,123,114,118,121,116,108,116,123,124,127,136,143,145,149,145,148,151,148,139,143,151,150,145,134,129,128,132,137,145,151,151,139,120, 113,117,119,116,111,114,127,132,123,107,86,78,79,81,87,98,106,109,114,115,118,116,114,121,137,150,153,154,152,147,147,146,147,142,137,129,126,128,129,131,126,134,143,150,160,156,152,150,150,147,149,159,162,161,153,148,143,146,138,125,128,130,122,109,99,93,98,98,88,96,113,126,121,117,125,133,134,131,136,142,135,125,120,114,109,107,106,105,104,109,112,112,107,99,97,99,110,125,141,146, 147,153,151,152,150,145,143,139,136,132,129,126,126,124,125,128,133,130,126,127,127,125,123,130,137,134,124,123,130,133,136,142,140,141,140,144,144,138,130,126,118,113,111,107,116,126,133,130,118,112,119,119,114,116,118,123,125,122,117,112,111,108,117,119,116,117,116,112,114,121,125,125,130,138,146,144,142,138,140,140,133,136,139,141,141,138,129,127,136,139,141,143,141,143,141,135,133,134,135,143, 147,149,151,154,148,139,136,128,125,121,124,128,133,133,124,123,119,118,119,123,127,135,143,136,134,141,153,160,159,154,147,134,113,98,99,102,107,112,115,116,119,118,115,114,114,117,118,127,134,140,138,129,132,134,134,127,118,115,111,110,104,103,108,116,130,144,149,146,148,136,125,125,132,136,137,144,145,143,131,123,121,117,108,109,118,122,118,110,104,106,113,115,117,119,122,127,121,117,113,118, 121,117,117,118,121,120,116,95,84,92,102,102,102,110,112,116,118,124,130,139,151,158,160,149,145,142,136,135,135,143,146,139,127,124,129,130,122,122,135,151,156,148,139,139,142,138,139,145,150,149,146,146,154,159,159,149,138,136,132,128,121,123,129,130,130,133,135,130,123,123,129,132,132,131,132,140,144,138,128,123,120,119,109,102,107,106,107,104,110,116,119,121,122,128,135,133,130,137,142,143, 135,129,138,141,136,126,119,123,130,131,128,128,133,141,143,145,142,143,138,131,131,136,141,141,141,140,142,144,145,144,136,126,121,124,124,117,109,104,105,100,95,94,99,99,98,100,102,106,110,109,115,128,134,127,124,126,126,119,109,112,115,121,120,117,120,118,117,115,109,107,113,124,129,132,128,125,125,130,133,137,134,129,129,120,114,105,111,127,141,150,152,153,146,134,125,124,134,142,143,146, 151,154,156,153,156,153,143,139,140,147,141,134,130,132,134,135,136,133,126,116,117,118,119,123,126,131,142,151,147,137,134,132,129,122,121,125,125,118,113,121,123,133,134,128,129,133,135,132,133,136,142,141,139,136,136,129,120,122,126,129,133,135,138,144,152,150,148,147,151,153,143,137,135,138,135,127,120,119,121,122,119,111,109,109,112,116,115,115,114,113,111,112,111,103,101,98,95,100,103,102, 103,107,110,117,124,124,123,124,121,118,123,128,128,127,128,125,128,125,121,122,122,122,120,123,119,112,112,113,115,117,114,111,117,120,117,118,121,127,134,140,144,149,156,153,147,146,149,149,151,149,149,150,147,144,141,138,138,142,142,147,149,144,134,130,135,134,130,129,131,133,127,116,114,117,120,119,120,124,127,126,127,127,128,127,123,120,121,125,122,122,123,127,131,126,130,138,147,149,144,139, 136,144,144,138,136,134,127,120,119,125,134,134,131,133,142,144,139,138,138,146,146,141,137,135,131,127,124,119,120,114,106,103,105,111,111,113,116,117,121,125,128,129,124,117,115,117,119,117,117,120,121,122,123,126,126,122,114,115,123,120,118,113,110,114,118,125,129,131,130,127,126,127,130,131,129,126,129,134,128,118,114,118,117,117,120,125,126,123,124,130,137,140,147,150,148,149,145,141,137,136, 138,145,149,150,145,135,130,127,127,129,132,132,129,127,129,131,125,124,123,127,129,128,124,117,114,114,119,126,130,128,124,119,116,118,118,116,111,112,118,123,126,124,127,128,131,136,147,156,152,149,142,142,144,143,138,134,135,133,131,127,123,120,119,121,126,134,139,136,133,134,134,136,139,138,136,132,131,130,129,125,120,117,114,120,126,123,117,112,111,110,110,116,118,122,123,122,124,126,127,128, 130,132,133,136,136,132,128,125,125,128,130,126,122,117,114,115,116,116,121,126,131,133,131,129,129,130,126,125,130,132,129,125,120,120,122,119,118,123,129,133,135,136,136,140,138,136,139,144,144,141,143,143,144,143,139,138,137,135,133,132,132,131,129,127,125,123,117,111,109,115,118,114,110,111,118,121,122,124,128,131,135,134,133,136,136,131,126,124,127,128,126,124,124,126,125,126,129,132,135,137, 139,139,140,138,136,136,136,139,139,136,131,128,128,126,128,129,128,125,124,120,117,114,111,110,111,114,117,119,118,118,117,118,120,124,129,131,131,133,132,128,125,124,125,125,127,126,122,119,116,115,117,122,128,133,137,136,136,136,135,133,131,130,129,129,127,126,124,124,125,128,130,130,132,131,131,131,131,132,132,133,135,137,138,139,137,135,134,135,140,142,140,137,135,134,134,132,131,132,133,130, 126,126,128,130,130,131,135,138,140,135,132,132,131,130,126,124,123,121,118,114,114,111,107,104,106,109,111,113,116,117,121,125,127,130,130,132,132,129,130,133,133,131,130,131,130,128,126,126,125,124,122,121,122,122,123,124,126,132,136,134,133,133,134,135,133,132,132,131,129,126,123,119,114,112,113,115,117,120,124,126,127,127,129,131,136,140,141,142,143,141,140,137,135,136,135,133,131,127,125,123, 122,123,125,127,128,127,128,130,129,125,124,127,128,128,129,130,130,128,125,124,124,125,125,125,123,123,124,122,123,125,126,127,129,133,137,138,138,140,141,141,141,139,138,137,135,131,127,125,125,123,120,120,122,124,124,124,125,127,129,130,132,134,134,134,130,128,127,126,124,120,119,118,117,117,119,120,122,123,125,126,128,129,132,136,137,139,139,140,141,140,139,138,138,137,136,134,131,128,125,123, 122,123,122,121,122,121,122,123,124,125,128,130,132,132,130,129,128,127,126,125,125,123,123,122,121,120,120,120,122,122,122,122,122,122,122,123,123,123,124,124,124,124,124,124,124,124,124,124,124,125,126,125,124,124,122,122,125,129,131,128,126,126,128,127,127,128,126,126,126,126,127,129,130,131,132,133,134,135,135,136,136,136,137,137,137,137,137,138,138,140,140,138,136,136,137,137,133,132,132,132, 132,132,131,131,130,130,130,130,131,133,133,134,136,134,133,130,127,127,126,125,125,126,126,125,124,126,127,127,125,123,124,125,124,123,124,124,125,126,126,128,129,127,126,125,125,124,121,118,119,119,118,117,118,119,119,120,121,121,119,119,119,122,126,127,127,126,127,128,127,126,127,128,127,126,127,129,130,130,130,132,132,133,132,131,131,132,133,134,135,137,135,133,131,129,127,124,122,125,128,129, 130,129,127,127,127,126,128,129,130,129,127,125,124,122,122,123,125,126,126,125,123,122,122,124,126,127,127,128,129,130,131,132,132,134,137,140,143,144,141,138,136,135,135,134,134,135,134,132,128,126,126,126,125,125,125,125,126,125,124,125,126,128,129,131,132,132,130,128,127,127,126,125,125,125,125,126,126,126,126,126,127,129,131,132,131,130,130,131,131,132,133,134,132,130,129,128,126,124,122,122, 120,121,122,123,123,124,125,127,128,128,128,128,128,128,130,130,129,130,130,129,129,128,127,126,126,126,127,126,125,125,125,125,124,124,124,124,124,124,124,124,123,123,123,124,124,124,124,124,124,124,124,124,123,123,124,124,123,125,127,127,127,128,130,132,133,132,132,133,133,132,131,128,129,130,130,131,132,133,134,134,134,134,134,135,136,136,136,136,136,136,135,134,134,134,135,135,133,131,129,128, 126,127,128,129,130,128,128,126,124,124,125,125,125,126,128,128,127,127,127,127,127,128,128,130,131,130,129,128,127,127,126,128,128,130,129,126,124,124,126,127,128,130,129,127,127,125,122,120,118,118,119,121,124,125,124,124,124,124,124,124,124,122,123,124,124,123,123,123,124,126,126,126,126,126,125,124,125,128,131,132,132,132,133,132,130,129,128,128,127,127,128,130,132,132,131,131,131,131,130,129, 129,129,127,127,127,126,126,125,125,126,126,125,126,128,128,127,127,128,129,130,128,127,127,126,126,127,128,130,132,134,134,135,135,135,134,133,134,135,135,133,133,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,131,131,131,131,131,131,131,131,131,131,131,131,131,131, 131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,130,130,130,131,130,130,130,130,130,130,130,130,130,131,131,131,130,130,130,130,130,130,130,130,131,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130, 130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129, 129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128 }; const uint8_t CL[] PROGMEM = { 125,122,122,128,130,125,120,130,141,134,111,110,134,149,124,100,119,158,147,100,87,131,154,125,90,96,111,125,137,137,109,121,175,166,61,40,146,201,126,94,144,166,129,107,87,110,195,219,89,23,121,199,138,90,94,124,173,194,101,54,146,216,130,63,90,157,208,196,65,6,117,247,196,95,32,64,173,244,125,18,63,177,205,166,52,22,136,255,183,68,14,85,199,255,136,17, 42,165,215,201,89,38,103,223,211,144,52,60,138,242,201,116,25,68,165,253,165,76,15,103,201,255,127,37,28,160,207,247,95,43,1,208,85,97,146,1,54,164,25,239,103,1,14,145,235,255,143,38,1,66,153,41,254,105,1,19,30,234,32,198,176,22,1,19,98,255,104,89,149,1,24,19,178,245,255,238,112,2,2,18,115,246,26,225,184,37,2,4,25,207,116,1,203,190,47,11, 1,41,110,255,102,107,255,61,39,1,19,43,185,238,255,246,218,88,20,1,11,8,135,209,255,151,51,237,39,43,1,39,2,180,115,94,170,54,230,97,51,1,1,24,64,201,143,82,182,38,244,59,75,1,29,1,107,143,255,173,1,136,230,103,86,6,11,1,28,103,152,230,153,1,191,215,140,93,53,15,1,12,70,139,109,235,50,180,255,153,206,117,49,1,13,1,57,88,125,191, 31,240,255,200,214,147,111,30,7,1,19,57,70,94,184,239,255,250,237,190,201,163,82,1,10,1,29,45,70,102,192,235,255,25,210,214,196,186,109,45,1,10,1,47,33,76,93,234,179,49,255,200,236,192,196,125,61,1,8,1,26,37,44,75,126,245,42,198,255,199,239,193,202,120,77,1,16,1,36,17,57,33,133,150,255,93,116,255,195,234,203,193,111,47,1,6,1,23,27,42, 49,94,155,218,247,255,244,223,219,221,201,155,97,44,8,1,6,26,30,34,44,83,147,217,253,253,241,231,224,222,218,198,152,103,50,12,1,8,23,25,27,37,54,89,139,186,221,246,249,237,226,227,225,218,201,173,133,96,61,29,9,11,16,19,24,32,36,54,84,120,156,194,218,230,236,241,232,226,224,223,210,193,167,139,113,94,68,46,28,18,13,19,23,29,35,52,67,88,109,136, 159,186,204,215,219,226,226,224,217,213,204,196,183,170,152,137,114,93,74,64,49,41,33,33,31,37,41,50,58,72,83,97,112,132,150,171,184,194,199,207,207,209,205,204,198,197,190,184,174,168,156,145,128,113,98,89,76,68,57,53,48,50,50,53,54,61,64,72,78,90,101,118,129,142,152,167,175,186,188,193,192,195,192,193,189,190,185,184,177,174,165,161,151,143,128,118,105,99,88,81, 72,68,62,64,61,63,61,66,66,71,73,80,84,95,102,112,119,132,141,155,161,168,171,178,179,183,182,185,182,184,182,182,178,178,174,173,167,163,155,151,140,132,122,117,107,101,91,87,80,79,74,74,70,72,70,72,71,75,75,81,83,89,92,100,106,117,123,132,138,147,153,162,164,169,170,174,174,177,175,178,175,177,175,175,173,173,170,169,164,162,155,152,144,139,130,123,115,111,103,99, 92,89,84,84,80,80,77,78,77,79,78,81,81,84,85,90,92,98,102,109,114,120,125,132,137,145,148,153,155,160,161,164,165,167,166,168,168,170,169,170,169,170,168,169,167,167,165,164,160,159,154,152,147,144,138,134,128,125,120,116,111,108,103,102,98,97,94,93,91,91,88,88,87,88,87,88,87,88,87,88,89,91,92,96,97,101,103,107,110,116,119,123,125,130,133,138,140,143,144,148, 149,152,153,155,155,157,158,160,160,162,162,163,163,165,165,165,165,165,165,165,165,165,163,162,160,159,156,155,152,150,147,144,141,139,135,132,128,125,123,121,118,115,112,109,107,106,104,103,101,100,98,98,96,95,94,93,92,92,92,91,91,91,90,91,91,92,93,94,95,97,98,100,102,105,107,109,112,114,117,120,123,125,128,130,133,135,137,139,141,143,145,145,147,148,149,151,152,153,155,155, 156,157,157,158,159,159,159,159,160,160,160,160,160,160,160,159,159,158,157,156,155,154,153,152,150,148,147,145,143,141,139,137,135,133,132,130,127,125,124,121,121,118,117,115,114,113,112,111,110,109,108,107,107,105,105,104,104,103,103,103,102,101,101,102,102,102,102,102,103,103,104,104,105,105,107,107,109,109,111,112,114,115,117,118,120,121,122,124,125,126,128,129,131,131,133,134,135,137,137,138, 139,140,140,141,142,142,142,143,144,144,145,145,146,146,146,146,147,146,147,147,147,147,147,147,148,147,147,147,147,146,146,146,146,145,145,144,144,142,142,141,141,140,139,138,138,137,136,135,135,133,132,131,131,130,129,128,128,127,126,125,125,124,123,122,122,121,121,120,120,120,119,118,119,118,118,117,117,117,116,116,116,116,116,116,116,115,116,116,116,115,116,116,116,115,116,116,116,116,117,117, 117,117,118,118,118,118,119,119,120,120,120,121,121,122,122,123,123,124,124,124,125,125,126,126,127,127,127,128,128,128,129,129,130,130,130,130,131,131,131,131,131,132,132,132,132,132,132,132,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,132,132,132,132,132,132,132,132,132,132,131,131,131,131,131,131,131,131,130,130,130,130,130,130,130,129,129,129,129, 129,129,129,129,129,128 }; volatile uint8_t MIDISTATE=0; volatile uint8_t MIDIRUNNINGSTATUS=0; volatile uint8_t MIDINOTE; volatile uint8_t MIDIVEL; volatile uint8_t MIDItriggers[8]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; ISR(USART_RX_vect) { uint8_t MIDIRX; MIDIRX = UDR0; /* Handling “Running status” 1.Buffer is cleared (ie, set to 0) at power up. 2.Buffer stores the status when a Voice Category Status (ie, 0x80 to 0xEF) is received. 3.Buffer is cleared when a System Common Category Status (ie, 0xF0 to 0xF7) is received. 4.Nothing is done to the buffer when a RealTime Category message is received. 5.Any data bytes are ignored when the buffer is 0. */ if ((MIDIRX>0xBF)&&(MIDIRX<0xF8)) { MIDIRUNNINGSTATUS=0; MIDISTATE=0; return; } if (MIDIRX>0xF7) return;

if (MIDIRX & 0x80) {
 MIDIRUNNINGSTATUS=MIDIRX;
 MIDISTATE=1;
 return;
 }

if (MIDIRX < 0x80) {
 if (!MIDIRUNNINGSTATUS) return;
 if (MIDISTATE==1) {
 MIDINOTE=MIDIRX;
 MIDISTATE++;
 return;
 }
 if (MIDISTATE==2) {
 MIDIVEL=MIDIRX;
 MIDISTATE=1;
 //if ((MIDIRUNNINGSTATUS==0x8A)||(MIDIRUNNINGSTATUS==0x9A)) handleMIDINOTE(MIDIRUNNINGSTATUS,MIDINOTE,MIDIVEL);
 //if (MIDIRUNNINGSTATUS==0xBA) handleMIDICC(MIDINOTE,MIDIVEL);

return;
 }
 }

return;
 }

void setup() {
  OSCCAL=0xFF;
  
  //6 TRIG inputs
    //PB4 - BD
    //PB5 - SD
    //PB0 - HH
    //PD7 - HT
    //PB7 - CL
    //PB6 - RD
    DDRB=0x06;
    PORTB=0xf1;
    DDRD=0x7f;
    PORTD=0x80;
    
    pinMode(1,OUTPUT);
    
    //6 DAC outputs   
    pinMode(5,OUTPUT);
    pinMode(6,OUTPUT);
    pinMode(9,OUTPUT);
    pinMode(10,OUTPUT);
    pinMode(3,OUTPUT);
    pinMode(11,OUTPUT);

    
    

    cli();
    
    TCCR0A = ((1<<COM0B1)|(1<<COM0A1)|(1<<WGM01)|(1<<WGM00));    
    TCCR0B = ((0<<CS01)|(1<<CS00));

    TCCR1A = (1<<WGM10)|(1<<COM1A1)   // Set up the two Control registers of Timer1. 
             |(1<<COM1B1);             // Wave Form Generation is Fast PWM 8 Bit, 
    TCCR1B = (1<<WGM12)|(1<<CS12)     // OC1A and OC1B are cleared on compare match 
             |(1<<CS10);               // and set at BOTTOM. Clock Prescaler is 1024.
    TCCR1B = (TCCR1B & ~(_BV(CS12) | _BV(CS11))) | _BV(CS10); //No prescaler

    TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
    TCCR2B = _BV(CS20);
    
    TIMSK0 = 0;
    TIMSK1 = 0;
    TIMSK2 = 0;

    OCR0A = 127;
    OCR0B = 127;
    OCR1A = 127;
    OCR1B = 127;
    OCR2A = 127;
    OCR2B = 127;
    
    sei();

   
    // Set baud rate to 31,250. Requires modification if clock speed is not 16MHz.
   UCSR0B = (1 << RXEN0);   // Turn on reception circuitry 
   UCSR0C = (1 << UCSZ00) | (1 << UCSZ01); // Use 8-bit character sizes UBRR0H = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register 
   UBRR0L = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register

    // USART RX interrupt enable bit on
    UCSR0B |= _BV(RXCIE0);

    // set up the ADC
    uint16_t SFREQ=analogRead(0);
    ADCSRA &= ~PS_128;  // remove bits set by Arduino library
    // Choose prescaler PS_128.
    ADCSRA |= PS_32;
    ADMUX = 64;
    sbi(ADCSRA, ADSC);

}

void loop() {
  uint8_t phaccBD,phaccSD,phaccCH,phaccOH,phaccLT,phaccHT,phaccCY;
  uint8_t pitchBD=128;
  uint8_t pitchSD=128;
  uint8_t pitchCH=128;
  uint8_t pitchOH=128;
  uint8_t pitchLT=128;
  uint8_t pitchCY=128;

  uint16_t samplecntBD,samplecntSD,samplecntCH,samplecntOH,samplecntLT,samplecntCY;
  uint16_t samplepntBD,samplepntSD,samplepntCH,samplepntOH,samplepntLT,samplepntCY;
  
  uint8_t dread1,dread2,dread3,dread4,dread5,dread6;
  uint8_t odread1,odread2,odread3,odread4,odread5,odread6;

  
  int16_t total;
  uint8_t oldPORTB;
  uint8_t oldPORTD;

  uint8_t divider;
  uint8_t MUX=0;
  
  while(1) { 
    //midi.update();
    if (!(ADCSRA & 64)) {
      uint16_t pitch=((ADCL+(ADCH<<8))>>3)+1;

      if (MUX==0) pitchBD=pitch;
      if (MUX==1) pitchSD=pitch;
      if (MUX==2) pitchCH=pitch;
      if (MUX==3) pitchLT=pitch;
      if (MUX==4) pitchOH=pitch;
      if (MUX==5) pitchCY=pitch;

      MUX++;
      if (MUX==6) MUX=0;
      ADMUX = 64 | MUX; //Select MUX
      sbi(ADCSRA, ADSC); //start next conversation
          
     if (samplecntBD) {
            phaccBD+=pitchBD;
            if (phaccBD & 128) {
                phaccBD &= 127;
                OCR1A=pgm_read_byte_near(BD + samplepntBD);
                samplepntBD++;
                samplecntBD--;
                
            }
      }
      if (samplecntSD) {
            phaccSD+=pitchSD;
            if (phaccSD & 128) {
                phaccSD &= 127;
                OCR1B=pgm_read_byte_near(SN + samplepntSD);
                samplepntSD++;
                samplecntSD--;
                
            }
      }
      if (samplecntCH) {
            phaccCH+=pitchCH;
            if (phaccCH & 128) {
                phaccCH &= 127;
                OCR2A=pgm_read_byte_near(HH + samplepntCH);
                samplepntCH++;
                samplecntCH--;
                
            }
      }
      if (samplecntLT) {
            phaccLT+=pitchLT;
            if (phaccLT & 128) {
                phaccLT &= 127;
                OCR0A=pgm_read_byte_near(TO + samplepntLT);
                samplepntLT++;
                samplecntLT--;
                
            }
      }
      if (samplecntOH) {
            phaccOH+=pitchOH;
            if (phaccOH & 128) {
                phaccOH &= 127;
                OCR0B=pgm_read_byte_near(CL + samplepntOH);
                samplepntOH++;
                samplecntOH--;
                
            }
      }     
      if (samplecntCY) {
            phaccCY+=pitchCY;
            if (phaccCY & 128) {
                phaccCY &= 127;
                 OCR2B=pgm_read_byte_near(CY + samplepntCY);
                samplepntCY++;
                samplecntCY--;
                
            }
      }  

    }


//----------------- Handle Triggers ------------------------------
        //PB4 - BD
        //PB5 - SD
        //PB0 - HH
        //PD7 - HT
        //PB7 - CL
        //PB6 - RD

        dread1=PINB&16;
        dread2=PINB&32;
        dread3=PINB&1;
        dread4=PIND&128;
        dread5=PINB&128;
        dread6=PINB&64;
        
        if (dread1!=odread1) {
        odread1=dread1;
        if (odread1) {
          samplepntBD=0;
          samplecntBD=sizeof(BD);
        }
      }
      if (dread2!=odread2) {
        odread2=dread2;
        if (odread2) {
          samplepntSD=0;
          samplecntSD=sizeof(SN);
        }
      }
      if (dread3!=odread3) {
        odread3=dread3;
        if (odread3) {
          samplepntCH=0;
          samplecntCH=sizeof(HH);
        }
      }
      if (dread4!=odread4) {
        odread4=dread4;
        if (odread4) {
          samplepntLT=0;
          samplecntLT=sizeof(TO);
        }
      }
      if (dread5!=odread5) {
        odread5=dread5;
        if (odread5) {
          samplepntOH=0;
          samplecntOH=sizeof(CL);
        }
      }
      if (dread6!=odread6) {
        odread6=dread6;
        if (odread6) {
          samplepntCY=0;
          samplecntCY=sizeof(CY);
        }
      }


//-----------------------------------------------------------------



      
    }

}