Skip to content

Instantly share code, notes, and snippets.

Created January 26, 2016 18:51
Show Gist options
  • Save anonymous/d247f4b9a4456bb4ae06 to your computer and use it in GitHub Desktop.
Save anonymous/d247f4b9a4456bb4ae06 to your computer and use it in GitHub Desktop.
// dsp-L8 Latin Perc Chip (c) DSP Synthesizers 2015
// Free for non commercial use
// http://janostman.wordpress.com
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#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))
const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
//--------- Ringbuf parameters ----------
uint8_t Ringbuffer[256];
uint8_t RingWrite=0;
uint8_t RingRead=0;
volatile uint8_t RingCount=0;
volatile uint16_t SFREQ;
//-----------------------------------------
const uint8_t AG[1720] PROGMEM =
{
128,127,130,127,148,106,82,178,99,174,145,137,167,25,127,94,90,218,136,189,179,64,135,30,53,167,140,220,175,187,128,16,104,40,108,186,154,255,164,103,98,51,61,90,167,181,192,199,123,92,68,61,97,127,175,188,201,141,104,81,57,95,117,158,191,176,173,121,81,68,80,122,129,174,194,162,143,103,60,87,96,128,179,160,181,150,117,83,62,120,95,158,185,147,185,111,
104,90,66,127,128,171,167,155,162,92,96,99,80,135,148,156,181,134,139,111,80,106,93,149,148,158,183,119,132,97,89,112,101,162,152,160,151,121,124,88,110,105,123,163,141,168,136,117,116,99,112,101,147,154,140,167,125,114,113,100,118,108,147,161,145,158,109,116,118,86,133,118,148,169,134,157,90,116,121,86,147,116,170,159,122,153,80,122,113,102,151,122,171,150,123,128,90,125,110,116,
155,134,159,145,119,116,96,127,116,123,153,136,160,130,111,122,98,126,118,139,148,133,164,111,117,112,104,139,107,156,144,134,155,99,130,96,114,147,108,163,132,143,145,92,128,99,119,141,123,166,128,138,140,91,120,101,126,149,126,167,134,124,131,91,118,103,137,159,128,165,124,123,119,88,122,112,152,152,144,152,107,129,102,99,122,124,168,140,151,133,105,125,92,118,122,133,174,136,145,119,
104,124,89,127,134,143,173,132,139,106,96,130,94,138,145,146,172,115,131,101,97,134,101,154,141,146,168,103,121,98,111,132,114,162,138,150,145,104,114,96,126,132,131,152,141,150,121,110,110,106,133,129,148,146,132,145,114,110,106,114,143,129,150,144,126,141,103,114,112,112,158,130,150,139,119,141,90,121,118,117,167,127,154,127,112,139,90,124,119,135,162,125,149,118,114,127,104,129,121,143,
155,128,133,115,120,122,112,129,128,146,143,133,128,109,127,120,117,130,128,155,133,129,130,104,133,114,125,135,121,164,127,129,125,101,141,106,131,140,125,162,120,131,117,101,141,109,136,138,135,156,117,124,111,109,133,119,142,137,138,149,116,114,110,118,132,128,145,138,137,135,116,114,107,128,136,132,144,130,140,125,112,118,106,139,132,139,146,119,144,114,112,119,110,150,129,144,139,116,141,107,
120,120,115,154,131,140,133,117,134,107,120,123,124,153,133,137,128,114,131,113,119,127,132,150,131,135,122,116,128,114,126,126,138,148,130,131,114,125,122,117,135,124,147,138,129,129,104,131,120,124,136,124,152,128,127,126,105,134,121,130,138,124,149,126,121,122,110,136,124,132,139,125,144,123,121,122,112,139,127,132,136,128,140,118,122,120,119,138,128,139,129,130,135,118,123,114,133,135,129,141,
122,134,127,120,124,113,140,133,133,137,119,138,120,119,126,116,142,132,136,134,115,135,120,119,128,120,147,132,132,133,113,133,119,123,129,122,149,132,129,127,114,133,116,128,129,129,146,128,131,118,117,131,120,132,127,137,141,124,128,113,124,126,126,137,125,141,135,122,124,111,129,129,129,139,125,139,129,121,125,111,134,131,128,138,123,140,125,119,126,113,138,129,132,137,120,140,122,120,124,117,
140,128,134,132,122,135,120,125,121,124,140,128,135,126,126,131,119,126,120,131,137,130,135,121,127,129,120,126,122,136,137,128,135,118,128,127,121,131,118,139,135,127,133,115,131,124,121,133,120,142,132,128,130,112,133,124,125,132,125,142,128,128,126,115,131,125,129,130,128,140,128,126,121,120,131,125,132,130,130,136,126,126,117,124,132,128,135,127,133,133,121,127,116,127,133,129,138,123,133,131,
119,126,116,134,134,130,137,120,132,126,121,127,118,136,135,130,133,120,131,123,123,128,123,137,134,131,129,120,130,125,123,127,127,138,132,130,125,120,128,124,128,126,130,139,130,130,121,123,128,125,131,127,133,135,128,130,117,125,130,125,133,126,135,133,125,129,117,126,130,128,134,125,135,132,123,126,118,129,131,129,135,125,132,129,123,124,119,132,133,129,133,126,132,127,124,125,121,133,132,132,
129,125,131,125,124,123,126,134,131,133,127,126,129,125,127,122,129,134,131,131,124,127,129,124,129,123,129,135,129,132,122,126,130,123,128,124,131,134,128,132,122,126,130,124,129,125,132,135,126,129,122,127,128,125,130,126,132,134,128,126,121,127,129,127,129,129,133,131,127,124,122,127,129,129,129,130,133,129,125,123,123,129,129,131,130,128,133,127,125,122,124,132,128,132,129,129,132,124,127,122,
124,134,129,132,127,128,131,123,126,123,128,134,129,132,126,127,130,123,125,125,130,134,129,130,127,126,128,124,127,126,131,134,129,129,125,127,127,124,127,128,133,132,129,127,123,129,127,127,127,128,135,129,129,125,124,129,125,129,127,128,135,129,128,124,124,130,125,129,129,129,133,128,128,124,124,131,127,129,129,130,133,126,126,124,125,131,128,131,128,130,132,125,124,124,128,130,129,131,128,130,
128,127,124,123,130,130,130,128,128,131,127,126,124,125,131,130,132,128,127,130,126,126,124,127,132,130,131,128,127,129,126,126,125,127,134,130,130,128,126,129,125,127,126,128,133,130,129,125,126,129,125,126,127,131,132,129,128,125,126,127,127,126,127,132,132,129,125,125,127,127,127,128,129,131,130,129,125,125,128,127,128,128,129,132,129,127,125,124,129,129,129,128,128,133,127,126,124,125,130,128,
130,128,128,131,128,126,124,126,131,128,129,129,129,130,127,125,125,127,130,130,129,128,129,129,126,124,126,129,130,131,129,128,128,128,126,124,126,131,131,129,128,127,128,127,126,126,126,131,131,129,127,126,129,127,126,126,128,132,129,130,126,126,129,127,127,126,129,132,129,128,126,126,128,127,127,127,128,132,130,126,126,126,128,128,127,129,130,131,129,127,125,126,129,128,127,128,131,131,128,126,
126,127,129,128,129,128,130,130,127,125,125,129,129,129,128,129,130,128,127,125,125,129,130,129,127,129,130,127,126,126,127,130,130,129,128,127,130,128,125,126,128,131,129,128,128,128,129,127,126,126,129,131,129,128,127,128,128,127,126,127,130,130,129,127,126,128,127,128,126,128,131,130,129,126,126,128,127,128,127,128,131,130,128,126,126,128,127,127,128,129,130,129,128,126,126,129,129,127,127,129,
130,128,127,126,126,129,129,128,128,129,130,129,126,126,127,129,129,128,128,129,129,128,126,126,128,130,129,127,128,129,129,128,126,127,128,129,129,127,127,129,128,127,126,127,129,129,129,128,127,128,128,127,126,127,130,130,128,127,128,128,128,127,127,128,130,130,128,127,127,129,128,126,127,129,130,129,127,127,127,128,128,126,128,129,130,129,127,127,128,128,128,128,128,129,130,129,126,126,128,128,
128,128,128,129,129,128,126,126,128,129,129,127,128,130,129,127,126,127,129,129,129,128,128,129,129,127,126,127,129,129,128,128,128,129,128,127,127,128,129,130,128,127,128,129,128,126,127,129,129,129,127,127,127,128,128,126,128,129,130,129,128,127,128,128,128,127,127,129,130,129,127,127,128,128,128,127,128,130,130,128,127,127,128,129,127,127,128,130,129,128,127,127,128,129,127,128,128,130,129,127,
126,127,129,128,128,128,129,129,128,128,126,127,129,129,127,128,129,129,128,127,127,128,128,129,128,128,128,129,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,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
};
const uint8_t CA[2174] PROGMEM =
{
128,128,128,128,128,129,127,129,128,134,128,118,138,129,119,133,131,122,129,129,128,128,132,125,127,129,132,125,125,131,131,127,127,127,132,129,127,131,128,128,127,128,128,131,128,125,127,129,131,124,131,131,125,127,128,129,125,132,129,124,128,131,125,128,128,131,125,133,123,129,133,127,123,129,138,123,122,131,132,128,127,128,129,131,124,128,131,128,128,129,125,129,124,128,137,124,
128,125,131,125,131,133,128,124,127,132,128,122,136,129,124,125,134,129,124,132,128,131,123,133,128,122,134,128,127,131,129,127,123,132,131,122,131,131,127,129,131,124,131,127,128,131,124,133,124,132,125,129,131,131,125,133,122,133,129,124,134,120,133,128,138,114,125,134,129,127,131,131,125,127,124,141,127,117,138,137,119,118,134,137,132,120,127,127,127,139,124,125,131,128,133,118,129,138,115,143,
122,131,131,119,131,134,132,118,136,125,123,134,127,118,147,129,112,125,141,134,112,142,122,134,114,137,134,124,136,109,146,122,131,133,112,134,142,114,129,123,151,120,114,131,138,124,127,148,95,142,137,115,125,141,133,117,127,132,120,143,122,115,146,125,118,128,139,123,118,139,132,105,149,134,124,113,146,132,89,168,132,114,93,163,143,108,128,114,143,134,127,120,120,127,149,114,131,131,125,123,
136,123,139,123,124,143,107,134,131,125,143,120,123,132,105,146,159,109,108,153,115,118,139,136,136,119,117,127,122,158,118,119,141,137,78,153,162,103,143,114,127,124,146,118,129,131,119,142,125,115,124,152,110,125,157,99,125,128,153,120,95,138,163,115,97,156,133,117,131,129,133,132,131,85,159,158,112,93,154,156,97,129,125,128,124,168,83,133,152,123,117,120,151,127,105,128,137,148,119,127,
108,144,136,113,138,105,164,134,97,122,139,138,120,131,128,122,169,85,107,171,151,69,159,124,137,109,114,175,114,93,146,152,113,118,115,159,114,138,103,164,123,81,152,158,134,68,154,182,55,124,159,152,81,138,139,128,127,119,117,148,134,125,114,148,88,139,187,70,143,134,108,136,151,95,156,132,88,147,143,119,138,102,136,144,134,83,188,110,110,124,132,169,80,134,129,156,99,112,156,110,
151,146,80,127,149,110,166,120,87,146,161,87,119,168,144,89,90,176,143,109,92,235,79,104,108,187,114,122,124,60,255,56,105,168,137,113,94,148,147,133,112,103,168,119,119,109,162,115,113,153,127,113,99,188,100,137,132,113,136,127,98,162,151,89,141,139,115,84,177,152,119,89,120,137,159,153,80,133,122,149,139,97,103,171,163,81,103,153,159,93,139,136,102,148,136,122,99,168,105,144,
127,100,129,147,142,134,115,78,169,158,99,120,129,147,151,66,163,114,141,131,112,176,83,93,152,202,85,92,164,102,178,84,118,169,115,153,66,148,134,127,143,125,110,128,147,117,146,99,136,144,142,98,112,180,92,149,154,50,167,154,108,127,118,120,141,144,128,120,100,159,100,161,151,68,131,153,149,84,127,168,117,115,119,114,182,99,94,205,98,87,147,143,136,128,97,146,156,89,128,146,
127,137,117,119,133,144,99,118,151,173,97,73,167,142,115,131,107,146,152,102,88,162,168,97,127,104,163,115,151,98,168,123,45,235,97,58,222,103,110,119,167,99,127,137,138,148,39,185,181,107,27,181,186,56,171,146,22,225,139,70,162,122,89,212,60,99,235,56,122,123,191,84,125,134,143,132,85,161,100,173,134,88,122,163,78,168,144,80,151,157,156,30,123,206,137,95,137,76,143,210,
81,107,162,84,128,185,97,141,131,65,180,139,105,138,95,171,118,103,157,100,147,142,112,104,167,114,108,142,151,89,138,166,93,144,114,162,79,131,183,103,103,141,136,115,139,124,115,147,104,173,90,104,163,139,147,73,152,133,124,125,123,158,119,81,144,200,58,97,208,118,63,143,231,69,56,180,186,41,168,124,100,172,87,134,138,134,83,193,112,108,138,134,103,156,137,112,128,112,127,163,
107,112,197,45,162,134,105,156,117,134,137,78,161,146,102,127,151,99,139,138,138,104,124,156,105,146,115,112,123,168,105,129,128,119,136,134,127,105,147,152,92,134,131,119,182,74,99,172,133,124,107,131,138,129,124,136,108,133,152,102,120,154,141,98,95,182,129,115,143,112,108,162,134,69,181,144,90,128,131,176,78,138,129,120,123,158,114,112,139,131,148,95,119,154,149,88,129,146,120,123,
136,133,132,93,163,122,114,154,113,127,134,93,176,118,125,115,125,167,75,143,144,139,105,103,156,143,131,105,114,158,129,118,118,114,171,125,98,109,177,138,109,85,147,167,133,95,128,131,124,149,104,156,97,129,134,139,129,112,141,105,151,115,127,153,98,156,100,149,110,115,167,124,127,85,139,161,142,89,123,124,148,144,89,152,119,127,136,108,143,136,120,125,125,134,132,137,100,137,139,118,
129,134,133,109,141,124,125,125,131,147,123,103,137,137,133,124,117,129,118,137,144,115,137,131,107,137,120,161,104,115,153,125,103,147,124,110,181,95,112,148,122,142,120,114,139,114,157,104,125,147,123,117,131,115,148,144,93,146,123,127,118,159,112,104,149,134,136,109,129,120,148,133,94,153,123,120,141,127,125,113,142,136,108,152,114,118,147,107,144,137,94,149,133,110,143,131,109,128,154,113,
125,123,129,129,136,119,137,128,113,131,142,144,83,152,152,92,134,147,113,138,122,123,122,141,139,110,123,141,127,132,110,148,109,127,173,87,128,114,163,131,102,138,133,105,149,147,78,143,162,128,81,146,144,120,133,110,136,113,151,142,93,127,147,148,99,120,158,127,98,125,162,118,109,143,124,122,129,132,139,115,128,129,118,148,122,110,152,125,114,129,137,108,152,132,108,124,139,136,123,118,
128,141,129,115,129,134,119,141,132,118,119,142,119,138,127,120,134,120,133,131,127,124,128,128,128,128,136,117,129,133,115,138,127,128,139,119,120,133,128,133,124,124,132,124,123,134,128,127,124,127,132,129,124,127,132,128,125,124,134,132,131,113,136,133,110,138,132,131,128,122,131,123,129,137,124,123,124,131,139,114,128,134,123,127,131,131,123,129,132,117,134,132,125,129,124,129,123,132,131,131,
122,129,128,124,131,137,123,123,132,124,132,129,125,125,128,128,132,127,124,132,127,131,124,129,128,125,127,133,125,125,133,123,124,139,118,125,142,122,123,132,129,124,136,117,133,133,115,129,138,129,120,122,132,133,124,132,129,119,127,139,125,120,133,127,129,127,131,125,125,132,124,133,124,127,131,127,129,127,124,137,120,128,139,117,129,132,124,128,132,125,128,127,125,131,132,124,127,125,128,133,
123,125,133,128,124,127,129,133,124,125,129,131,124,129,125,128,133,125,125,128,128,132,129,125,124,129,127,131,132,124,127,127,133,123,129,131,128,120,133,134,118,129,132,124,133,125,122,133,136,117,125,136,131,122,124,137,124,129,123,134,128,119,131,131,127,129,127,127,132,127,124,134,123,125,136,124,128,125,129,129,123,133,124,129,127,131,127,129,128,123,131,127,127,132,127,127,128,125,132,127,
128,127,129,124,132,131,127,128,124,129,133,127,125,128,129,127,128,131,125,128,122,134,133,123,123,136,127,124,129,127,134,124,124,133,124,129,132,125,125,128,133,123,132,131,123,132,128,123,133,128,127,127,129,129,128,125,125,134,125,124,132,127,124,133,127,125,132,123,131,128,125,131,131,125,125,131,125,128,129,124,132,128,128,127,127,132,124,131,128,128,129,124,128,132,129,125,127,128,132,127,
123,133,125,127,132,124,129,127,128,132,127,123,131,131,128,125,125,131,129,129,125,124,131,129,128,125,128,129,125,128,129,127,128,129,125,128,131,127,128,129,127,127,127,131,131,122,129,134,123,127,128,129,129,123,131,129,127,128,128,128,127,133,125,124,128,133,127,124,128,129,131,125,127,131,127,125,132,125,127,131,128,125,128,129,128,127,127,129,127,129,127,129,127,125,132,127,125,132,127,125,
129,127,129,127,128,129,127,128,128,128,124,131,128,124,132,128,124,132,127,124,132,128,125,124,132,129,125,128,129,127,128,132,125,127,129,128,128,127,125,128,132,127,125,127,129,131,125,125,129,129,128,125,127,132,128,127,127,129,128,127,128,129,128,125,128,131,128,127,127,131,128,124,131,128,127,128,127,129,127,125,134,127,124,129,128,128,128,128,127,128,128,128,128,129,128,128,125,128,129,129,
129,124,129,129,124,131,129,125,128,128,129,128,127,128,131,125,128,129,129,127,128,129,125,129,128,128,128,128,127,125,131,129,127,127,128,127,128,129,127,129,129,125,128,129,129,127,127,128,129,129,127,124,129,129,127,127,127,127,131,128,127,128,128,129,128,125,128,129,127,125,131,131,124,128,129,127,127,128,129,128,127,125,129,128,129,128,125,128,128,129,125,127,132,128,124,127,129,129,128,127,
129,127,127,128,129,128,125,129,128,129,128,127,128,128,131,127,127,128,127,129,127,128,129,125,129,128,128,127,127,131,127,125,129,129,128,127,128,128,128,127,127,129,129,128,124,129,128,128,127,129,127,129,129,125,128,129,128,128,127,129,129,125,128,128,128,128,127,129,128,125,128,129,128,127,128,127,129,127,128,127,128,129,128,128,128,128,127,128,128,128,129,127,127,129,127,128,128,128,128,128,
128,127,128,129,127,127,129,128,128,128,127,129,127,127,128,129,129,128,127,127,128,127,131,127,127,128,128,128,128,129,127,128,129,125,128,131,127,128,128,128,127,129,131,127,127,128,129,128,125,129,128,128,129,125,128,128,128,128,128,129,127,128,129,127,128,128,128,127,127,129,128,127,128,128,129,128,128,128
};
const uint8_t MA[394] PROGMEM =
{
128,123,132,129,130,131,115,137,133,124,124,130,127,146,104,137,120,161,97,104,190,121,61,196,130,68,178,118,114,137,144,94,174,84,135,187,46,184,150,62,129,182,63,138,196,83,113,153,160,40,208,95,87,255,3,158,169,80,153,102,162,132,70,204,104,96,153,141,132,66,197,121,118,88,173,135,90,154,137,86,163,150,46,235,47,191,99,96,233,9,216,102,89,195,102,101,
189,95,77,198,105,124,106,156,154,57,189,133,74,140,173,106,91,152,162,86,124,173,100,122,142,122,129,162,66,133,220,77,63,186,172,57,109,207,82,110,167,131,86,170,114,126,136,99,171,107,127,108,165,134,72,199,97,107,175,98,128,140,116,152,99,151,117,131,151,83,175,109,115,155,122,100,164,101,132,160,106,104,157,138,81,204,50,172,134,89,184,81,150,123,139,96,186,76,132,179,
84,135,140,120,116,162,85,161,134,112,119,135,139,135,85,156,150,82,172,112,121,135,129,128,126,120,146,135,64,216,85,112,176,88,157,98,159,107,122,158,103,127,151,109,131,132,113,139,146,104,124,159,97,143,129,119,147,103,146,126,131,116,133,142,119,112,154,124,108,148,111,146,125,119,130,132,133,119,132,130,122,133,140,107,136,138,113,136,124,138,118,138,120,131,131,123,131,118,143,129,
104,149,132,129,108,140,143,107,132,138,118,126,141,124,117,138,150,90,151,126,123,131,125,137,119,134,127,127,130,124,133,127,123,133,133,112,145,128,111,143,127,123,132,119,138,135,115,126,143,123,116,143,127,121,127,140,121,122,138,128,122,127,137,128,115,139,136,118,125,142,119,129,127,132,125,123,140,122,124,132,128,129,129,122,136,126,126,128,128,130,127,127,128,129,128,128,128,128
};
const uint8_t WH[2670] PROGMEM =
{
128,128,128,128,128,128,128,128,128,130,127,121,130,133,122,122,137,131,115,128,143,122,111,139,142,110,116,153,131,97,135,160,107,99,161,149,82,121,179,116,75,160,174,75,97,194,134,53,146,199,84,66,195,170,39,112,225,112,31,177,210,45,71,229,154,17,135,240,84,26,203,207,30,74,242,148,9,140,245,87,23,199,211,41,68,229,169,25,111,233,125,27,152,225,90,43,
181,203,67,68,200,177,54,94,205,150,56,118,200,129,63,139,189,113,74,151,176,100,89,159,160,97,104,161,146,98,114,160,136,100,128,151,127,109,134,141,124,119,130,136,126,123,129,131,129,126,128,127,131,129,124,128,132,126,124,130,133,125,124,132,132,124,124,135,132,119,127,139,126,115,135,143,115,114,147,138,102,125,159,122,95,145,160,98,101,172,143,73,132,186,102,73,176,168,60,112,
205,113,55,171,184,59,103,208,117,55,171,179,61,112,205,105,64,187,162,47,136,206,78,73,208,145,35,153,211,64,72,219,144,29,154,217,62,68,221,148,29,153,216,63,68,219,149,29,150,219,67,60,216,162,25,132,233,87,33,200,199,32,87,236,140,19,144,231,88,40,188,200,59,78,202,163,61,109,194,137,71,131,178,122,89,139,159,120,102,137,152,120,106,135,151,122,104,137,154,117,
101,144,155,106,103,155,149,94,113,166,134,88,132,167,115,91,149,162,99,98,165,150,83,115,180,127,72,143,183,94,80,181,159,62,120,198,108,66,173,168,67,116,192,109,77,174,154,71,137,181,87,96,189,128,63,163,179,66,105,204,116,52,173,188,55,95,218,124,34,169,207,57,75,220,147,26,140,226,84,45,197,192,41,87,222,144,34,137,216,101,55,169,188,82,86,178,156,84,115,167,
134,99,130,150,126,116,130,135,130,124,122,133,139,119,116,143,140,106,121,156,129,94,137,163,104,95,164,152,80,116,185,120,67,159,182,72,90,200,137,46,149,204,72,74,208,143,41,153,200,69,89,205,127,55,166,179,64,113,203,105,62,187,165,45,127,216,89,53,201,174,28,117,233,97,31,194,204,36,76,233,149,18,135,235,95,32,180,210,64,66,199,176,58,96,197,150,70,115,184,136,
80,127,173,125,90,133,163,121,99,137,156,116,104,140,151,116,106,143,151,108,105,156,147,91,116,172,127,78,145,176,89,89,184,146,56,137,201,84,69,200,155,40,137,211,80,68,204,151,42,145,203,73,84,207,133,47,164,192,59,93,215,125,37,171,203,51,77,224,144,22,146,229,76,39,204,194,38,88,224,144,37,132,211,114,63,150,183,109,87,147,164,116,97,140,160,116,97,145,159,106,
99,156,154,94,108,167,141,84,123,173,125,82,140,174,103,85,166,162,76,108,189,126,63,152,188,80,81,197,146,44,142,206,79,71,201,150,45,144,199,80,82,198,139,55,154,188,73,94,202,129,50,162,194,63,82,214,144,29,144,225,77,42,201,194,37,87,226,145,33,134,215,110,58,157,187,99,86,157,163,106,105,146,151,114,106,142,153,112,101,149,156,99,102,164,149,82,114,180,129,72,
139,185,98,75,175,167,62,108,202,120,51,165,192,63,89,209,131,43,160,198,64,88,209,127,52,165,186,65,103,204,116,58,170,182,59,104,211,117,44,172,197,53,80,221,146,24,138,228,90,36,188,203,56,73,207,163,52,112,201,133,69,134,177,123,91,135,162,125,99,129,158,128,97,130,162,122,91,141,166,107,89,158,164,85,97,183,144,62,128,199,101,60,182,176,50,108,215,109,44,185,
185,43,107,221,102,50,191,173,48,124,207,92,69,194,153,48,144,202,75,76,206,144,38,149,213,70,58,213,167,24,119,234,106,25,175,216,62,60,207,177,48,102,206,142,62,131,186,122,86,138,162,121,103,133,153,127,102,130,159,122,93,138,166,110,89,156,165,89,96,178,147,68,125,191,109,66,170,176,63,105,204,117,51,173,184,53,104,214,110,49,182,180,48,114,214,100,59,190,166,48,
128,208,88,66,197,164,38,127,221,91,41,196,193,32,89,236,132,16,152,230,82,40,193,197,56,83,203,156,66,118,183,131,90,132,160,128,107,125,150,137,104,118,157,137,91,123,173,124,76,144,180,92,79,182,160,58,115,205,109,53,178,183,49,103,218,109,41,186,188,41,107,222,103,46,190,178,46,122,212,96,63,192,162,47,135,209,85,63,202,163,31,127,228,90,33,197,202,33,78,235,
149,17,134,232,98,40,176,199,77,79,185,162,82,110,171,142,96,121,156,138,104,118,152,142,102,113,161,143,86,119,176,127,69,143,187,91,73,184,163,53,118,209,103,53,183,179,45,112,218,104,48,187,181,44,114,215,102,58,189,167,51,128,204,92,72,191,156,50,135,206,85,61,201,167,34,118,230,98,30,184,210,46,67,221,164,32,116,221,123,51,149,193,104,83,158,164,103,109,150,144,
111,118,140,142,118,111,140,150,110,101,154,156,90,103,177,143,66,127,191,106,66,173,173,60,109,204,111,56,179,176,54,115,209,102,59,186,168,51,127,205,92,70,190,154,56,137,198,87,76,193,153,48,136,209,86,59,196,175,37,107,225,120,32,160,213,75,58,193,180,59,98,198,143,68,129,181,120,89,143,159,117,103,140,151,121,105,135,155,119,97,140,162,108,90,158,164,84,98,184,140,
62,137,191,92,76,185,154,57,134,198,87,77,194,146,52,144,197,77,85,200,136,55,153,188,74,94,197,131,56,158,189,69,90,204,137,42,151,208,74,58,203,175,35,105,223,126,36,152,210,90,63,178,177,81,98,176,150,87,119,165,135,99,127,154,132,104,124,154,135,97,123,164,130,83,134,177,106,78,165,169,71,101,195,128,56,156,188,70,91,201,129,52,164,186,63,101,206,118,58,172,
175,63,114,198,109,70,176,163,64,124,196,101,69,180,169,55,111,211,113,42,167,204,62,67,209,168,35,110,219,126,46,149,199,101,75,163,171,95,101,161,150,99,115,154,141,106,117,148,141,109,112,151,146,97,111,168,140,77,127,184,108,71,166,172,69,103,198,121,56,165,182,63,105,205,112,58,175,175,60,115,201,108,66,178,166,63,121,197,104,70,180,163,59,120,203,104,58,179,182,52,
95,216,133,35,147,213,86,55,183,184,68,90,192,152,71,119,181,129,88,134,163,121,101,136,154,123,104,134,155,122,98,137,161,113,90,152,166,91,90,179,152,62,122,198,107,61,173,178,57,106,207,112,57,176,177,56,111,207,105,61,183,168,55,124,202,94,71,188,157,55,133,199,91,69,190,163,50,121,212,105,47,175,195,58,79,210,155,41,123,209,118,59,153,187,98,87,163,159,98,110,
156,144,104,118,150,140,106,117,150,140,103,116,156,140,90,119,173,129,74,139,184,95,76,177,164,61,114,201,109,59,175,175,58,113,205,104,63,183,165,54,127,203,94,71,190,155,53,135,200,88,75,193,153,50,134,205,90,62,191,173,45,105,218,123,39,157,208,79,62,190,176,63,101,194,141,74,128,177,124,93,138,158,120,107,136,150,122,108,133,150,122,101,137,159,114,91,153,163,90,94,
179,149,62,123,198,106,61,174,177,56,105,207,115,55,174,177,59,111,204,108,63,181,168,57,123,201,97,69,186,163,53,125,204,98,60,186,174,49,110,215,114,41,168,203,65,70,205,166,44,112,210,128,55,144,193,106,79,157,167,102,103,154,149,108,114,147,143,111,114,145,145,107,110,154,147,93,110,172,137,73,129,187,107,65,168,180,66,92,202,135,46,151,200,73,78,203,143,47,150,198,
74,87,201,135,54,158,188,70,97,201,128,53,163,189,64,93,207,131,44,158,201,68,71,207,159,35,124,221,105,40,172,202,72,74,195,165,64,111,190,137,79,131,172,121,97,138,155,122,108,134,149,124,106,133,154,121,96,141,164,105,88,162,163,78,99,190,138,55,138,198,89,67,188,165,51,121,206,98,63,186,164,55,128,200,93,73,190,154,55,138,198,86,75,194,152,48,138,205,86,65,
195,166,44,115,218,110,42,170,201,65,71,203,165,50,113,205,128,61,146,186,106,87,155,161,105,109,150,146,112,115,143,143,115,111,144,149,106,105,158,149,85,112,180,130,65,142,190,90,69,185,165,52,115,207,107,55,178,177,57,111,204,110,64,179,167,59,124,200,98,73,187,157,54,130,202,92,67,190,166,46,117,215,105,44,177,198,56,77,211,155,41,124,213,115,55,158,190,92,86,171,
158,93,113,161,138,105,124,147,133,115,122,141,138,114,116,147,142,99,117,164,132,81,132,179,105,74,169,171,67,98,200,130,51,152,196,74,78,199,146,49,144,199,82,81,196,141,56,152,188,77,93,198,130,56,157,188,70,92,203,134,44,151,204,73,65,204,166,36,115,221,112,40,167,204,76,72,190,168,70,108,186,139,84,129,167,126,102,133,151,125,112,130,145,129,110,126,150,127,100,133,
160,114,91,153,162,89,97,179,145,63,127,195,104,64,173,175,60,103,204,119,56,167,182,66,104,199,118,65,169,171,67,117,195,108,69,176,168,61,115,204,109,54,177,184,55,94,214,131,37,149,212,81,57,191,183,57,93,202,146,63,129,188,120,85,145,165,113,105,144,148,116,114,137,145,120,109,138,150,112,103,150,153,96,105,169,143,76,122,186,113,66,160,182,72,88,197,142,48,142,201,
83,75,194,151,55,139,194,87,87,190,139,65,149,183,79,97,194,128,58,158,187,70,88,203,141,43,143,209,82,57,194,178,45,101,216,132,43,145,203,100,70,167,175,90,100,169,148,97,120,156,134,108,125,145,135,112,119,146,139,104,117,157,136,91,126,170,119,80,149,174,89,86,181,154,59,121,199,106,59,173,180,62,101,205,122,53,166,183,67,104,200,118,62,169,173,64,113,200,110,63,
176,174,56,110,209,112,48,173,191,56,85,214,142,37,140,213,93,54,181,186,69,91,193,151,70,124,182,126,89,138,161,120,107,135,149,125,111,130,147,127,106,131,153,120,100,141,157,106,98,158,153,88,108,177,137,69,132,189,99,69,176,169,61,109,201,117,57,167,181,67,104,199,118,62,169,174,66,115,196,109,68,176,165,62,120,199,104,62,179,173,54,109,211,116,46,165,197,67,76,202,
161,48,117,207,121,57,153,189,99,85,164,161,98,108,156,146,108,117,146,141,112,116,145,142,108,115,151,140,99,120,160,131,92,130,167,117,85,148,169,95,90,174,153,69,118,190,115,66,163,177,71,99,196,127,60,159,181,73,103,194,122,67,164,173,72,111,194,113,68,171,170,65,113,199,114,59,168,183,65,94,204,135,46,145,204,89,65,183,176,65,98,193,145,69,127,183,123,87,139,163,
119,104,138,152,121,108,135,150,120,106,137,153,114,104,147,151,104,106,156,146,94,113,167,137,83,127,176,113,79,155,170,83,98,186,135,64,145,184,85,89,187,140,64,145,184,85,92,186,136,67,149,180,84,95,186,135,65,148,185,84,86,189,146,57,132,198,99,65,175,177,66,95,196,145,61,127,190,120,77,146,174,110,95,150,155,110,109,146,147,113,113,144,144,112,114,147,141,105,117,153,
135,99,124,159,127,94,133,164,116,91,149,162,96,99,169,146,77,124,181,112,77,163,165,76,110,185,119,74,159,167,81,112,182,119,80,160,162,81,117,181,117,78,159,167,79,105,188,130,64,146,186,91,80,178,164,68,105,191,137,68,132,184,116,83,147,167,110,101,148,150,112,113,144,142,115,116,143,140,112,120,146,134,108,125,149,128,105,132,151,122,103,137,154,114,101,147,154,99,105,163,
143,84,122,175,118,79,151,171,89,96,177,142,74,132,180,107,85,164,157,84,115,176,125,82,148,166,96,102,169,142,84,129,171,115,89,151,159,102,106,156,144,103,119,149,135,112,125,139,131,122,128,130,130,129,127,125,129,132,127,125,129,131,128,128,128,128,128,128,128,128,128,128,128,128
};
const uint8_t TI[3680] PROGMEM =
{
129,129,129,129,129,129,129,129,129,129,128,130,140,165,197,212,220,219,224,224,238,178,65,16,1,18,23,56,144,135,95,196,193,74,43,47,46,44,38,41,40,42,35,34,23,111,210,141,124,180,176,168,184,197,206,208,207,202,201,181,100,104,148,147,157,179,177,171,178,193,209,211,209,198,182,168,171,152,124,126,121,104,104,109,109,86,54,86,86,47,42,57,78,107,131,115,
92,71,69,93,150,192,214,215,217,217,218,216,216,192,154,96,61,68,77,91,94,114,133,123,115,125,106,93,110,122,130,150,155,140,138,138,124,109,92,96,102,110,101,87,66,59,62,97,119,120,94,63,38,63,120,125,128,125,165,207,219,215,184,126,80,55,72,115,169,197,191,158,113,76,48,36,27,66,129,110,91,86,114,144,147,122,81,53,48,77,118,164,189,208,213,213,205,199,183,168,
161,155,151,160,168,163,176,192,193,186,174,159,154,165,169,168,158,150,145,145,144,134,113,91,93,92,93,90,99,117,161,203,212,209,190,175,160,139,148,168,175,182,188,183,181,195,196,187,183,143,78,45,26,25,33,51,58,81,111,127,135,140,119,94,95,99,105,126,143,141,143,144,144,137,126,95,67,49,41,43,58,72,82,84,84,88,98,109,112,112,113,118,133,160,182,194,189,166,133,97,
67,49,45,54,57,59,59,82,111,138,155,163,160,151,143,139,145,155,184,212,215,214,199,163,127,94,81,88,112,136,156,166,170,164,159,152,143,131,118,110,109,112,140,173,179,180,176,180,185,185,184,178,157,136,118,110,107,110,105,93,86,80,82,93,117,151,183,206,211,213,215,216,217,218,214,193,147,119,115,104,99,102,110,115,113,96,68,51,41,37,35,35,37,41,44,78,115,138,152,157,
168,173,173,171,167,155,149,148,140,134,132,126,113,86,66,53,54,61,69,81,92,100,105,107,114,119,120,107,93,97,100,103,110,119,127,136,139,134,121,104,90,78,73,72,82,98,130,168,175,180,188,193,194,190,185,181,180,188,204,205,199,190,177,163,155,148,142,134,126,118,110,102,100,99,95,101,115,129,147,163,162,155,149,144,148,169,189,205,202,190,180,158,135,116,103,96,93,93,96,100,
106,117,123,125,124,122,126,128,133,148,163,175,192,200,194,186,176,162,147,132,118,106,97,83,68,54,44,38,37,36,37,36,42,67,97,128,148,163,174,179,178,172,165,158,145,134,126,120,114,106,100,95,94,89,73,64,60,65,72,77,96,113,122,130,136,144,147,144,142,139,136,135,138,157,167,166,164,160,156,146,135,116,107,108,111,114,116,118,126,152,177,196,206,207,200,187,173,153,141,136,
135,138,146,147,143,145,149,152,153,148,139,120,102,97,96,101,105,108,110,115,122,127,136,149,164,175,175,174,172,169,160,145,119,91,67,58,61,68,82,98,108,114,118,121,123,127,129,126,124,122,120,120,122,125,128,130,130,131,137,143,148,147,145,143,128,108,86,74,70,72,76,78,78,78,82,88,97,112,123,127,139,149,150,148,142,131,117,103,98,98,103,108,109,112,112,108,102,97,99,97,
90,90,92,98,110,124,134,150,166,173,176,180,179,176,175,176,178,177,174,169,163,156,142,130,120,116,116,119,124,133,153,162,161,167,167,160,143,127,123,118,114,114,120,130,145,159,170,173,168,162,156,152,144,136,133,128,120,118,116,116,113,109,107,107,112,120,132,147,154,155,148,133,115,97,82,69,67,72,76,86,98,118,133,142,144,142,139,137,136,133,130,126,121,117,115,116,120,124,127,131,
133,133,134,135,137,137,135,130,126,121,118,113,104,100,96,91,90,94,99,104,109,109,108,109,110,112,113,115,116,113,110,110,110,111,118,124,128,129,128,126,125,125,122,121,122,123,125,126,133,144,160,170,171,171,168,163,163,168,177,184,187,185,178,171,164,158,154,149,141,135,131,132,136,140,141,139,133,120,106,92,86,90,102,116,130,148,162,166,167,164,161,151,138,131,125,120,118,117,116,113,
109,106,105,107,109,110,114,118,123,126,126,125,115,102,98,96,95,95,97,101,108,116,125,135,146,151,152,154,153,150,145,135,120,109,98,88,85,88,92,98,104,117,126,126,122,116,113,111,112,115,119,120,121,121,120,116,112,111,113,117,120,124,128,132,135,137,137,130,125,121,111,107,111,113,113,115,117,120,123,126,128,128,127,129,133,138,142,144,145,144,143,144,146,150,159,168,173,175,174,171,
169,168,166,165,164,162,158,157,156,157,156,155,152,146,138,129,120,110,101,95,92,91,93,97,102,108,115,120,124,127,128,130,130,129,129,128,125,122,119,119,116,110,104,99,95,93,94,94,96,96,98,101,105,108,112,114,115,114,111,109,108,109,116,136,151,162,172,177,174,169,161,154,142,127,115,105,101,99,100,103,108,111,113,114,115,115,114,114,114,115,117,119,120,121,121,120,121,123,126,128,
131,136,140,143,144,144,141,138,136,135,135,135,134,132,131,131,132,133,134,133,132,131,129,128,128,128,128,129,130,133,137,146,162,174,182,186,187,182,178,173,167,160,154,148,144,141,140,140,139,137,134,131,128,126,125,125,124,123,120,116,110,105,96,89,91,94,99,105,112,118,123,125,126,123,117,109,100,91,89,90,94,98,103,105,107,108,108,107,106,103,100,100,101,101,103,106,110,114,118,121,
123,126,130,135,141,147,152,157,160,162,161,158,155,151,147,141,136,132,129,127,125,124,124,124,125,126,126,126,126,125,123,119,115,112,110,110,110,111,113,116,122,131,139,148,157,162,163,162,159,155,149,143,139,136,132,127,122,120,119,119,122,127,131,133,132,132,131,129,128,127,127,129,133,142,152,163,174,182,185,188,187,181,175,167,158,149,141,134,126,117,111,105,99,94,90,89,89,90,93,95,
97,98,98,101,105,110,116,121,127,131,133,134,133,132,130,128,127,123,116,105,92,79,74,74,78,83,90,98,106,114,118,120,120,119,117,116,115,116,117,119,122,125,128,131,134,139,144,150,155,158,160,162,162,161,159,157,153,151,149,146,144,142,141,141,140,139,137,134,130,124,117,110,105,99,93,90,87,85,86,90,95,105,118,131,142,151,157,162,168,171,172,171,168,163,157,150,139,130,121,114,
109,106,106,109,112,116,119,122,124,125,125,126,127,130,135,145,158,172,182,187,186,182,177,170,164,158,152,146,140,131,122,112,103,95,90,87,85,84,83,84,85,87,90,94,98,102,107,110,112,114,116,119,122,124,126,127,126,125,123,121,120,119,117,113,109,105,103,102,102,104,107,111,116,121,125,128,131,133,133,134,134,135,135,135,136,137,140,143,146,149,151,151,150,149,148,147,147,146,146,146,
145,143,141,138,137,135,134,134,133,132,129,126,122,119,115,113,109,106,104,103,103,105,108,111,115,121,129,140,150,158,163,165,165,163,160,155,148,140,130,120,114,110,108,107,107,108,110,113,116,120,123,127,131,136,141,147,151,156,160,163,165,164,162,159,157,153,150,146,142,137,130,123,115,107,101,95,90,87,85,84,83,84,86,88,90,92,95,98,101,104,106,109,113,115,117,119,121,122,123,123,
123,123,123,123,122,122,122,123,123,123,123,123,124,124,125,125,126,126,128,129,130,132,133,134,135,137,140,146,151,157,162,164,164,165,164,163,161,159,155,152,149,145,142,138,135,133,129,126,124,121,119,117,116,114,114,113,112,112,112,114,116,119,122,125,127,129,130,132,133,134,136,138,139,140,141,142,141,139,137,135,132,128,124,121,116,112,109,107,107,107,108,110,113,117,120,126,133,139,143,147,
148,148,147,146,145,144,144,144,143,142,141,139,135,131,125,119,113,107,103,98,94,90,88,86,85,84,86,87,89,91,93,95,97,99,101,104,108,112,116,121,126,132,136,139,141,141,141,140,139,139,138,138,138,140,142,143,144,143,141,139,136,133,130,128,127,128,130,135,142,151,158,162,165,166,167,166,166,165,164,163,161,159,156,152,148,144,139,134,128,121,116,111,107,103,99,95,92,90,89,90,
93,97,103,110,119,127,134,138,140,141,141,140,139,137,135,132,130,128,125,123,122,121,121,122,123,124,125,125,125,124,123,121,120,119,119,120,122,124,127,129,130,132,133,134,134,134,133,132,132,131,130,129,128,127,126,124,123,122,121,119,118,117,116,115,113,110,107,104,103,102,102,102,103,104,105,107,109,111,114,118,121,126,131,135,138,140,142,143,143,143,143,142,142,142,142,141,141,141,140,140,
139,138,137,136,136,136,137,139,141,145,148,151,154,155,156,157,157,157,157,157,155,154,152,149,146,143,139,135,130,125,120,114,109,104,100,96,93,89,85,83,82,82,84,86,91,96,103,111,121,130,137,142,146,147,147,146,144,141,138,134,131,128,125,123,122,121,120,120,119,119,120,121,122,123,124,125,126,127,128,129,131,132,134,136,137,139,139,139,139,138,137,135,133,130,128,125,123,121,119,117,
117,116,115,115,114,112,110,108,106,105,103,103,104,105,107,110,114,118,122,126,129,132,134,135,137,138,140,141,143,145,147,149,150,151,152,151,150,149,148,146,144,142,140,137,134,132,129,127,126,126,128,129,132,134,136,138,140,142,144,145,147,148,149,150,149,149,148,146,145,142,138,134,128,121,114,107,101,97,93,90,87,84,82,81,82,83,85,88,92,96,101,106,111,117,124,130,136,141,145,146,
147,147,146,144,142,140,138,135,133,131,129,127,125,124,123,123,123,123,123,123,124,125,126,128,130,132,134,135,137,139,140,141,141,141,140,139,137,134,131,129,125,122,118,115,113,111,109,108,107,106,106,106,106,107,108,110,112,115,118,121,125,128,131,134,135,136,136,136,137,138,140,143,146,149,153,156,159,160,160,159,158,155,153,150,147,144,142,140,137,135,133,132,131,130,129,128,127,127,127,127,
127,128,128,129,129,130,131,132,133,134,134,134,133,132,129,126,122,117,112,107,103,100,97,95,93,91,90,90,90,92,94,97,101,105,109,114,118,123,127,130,133,135,137,138,139,140,140,140,140,140,139,138,136,135,133,132,130,129,127,126,126,125,126,126,127,128,130,132,134,136,138,139,140,140,141,141,141,140,140,140,139,137,134,131,126,121,115,110,105,102,99,98,99,100,101,103,106,109,113,117,
121,125,130,135,139,143,145,147,147,147,146,145,145,145,145,145,146,146,147,148,148,148,148,148,147,146,145,144,143,141,140,138,136,134,132,130,128,126,125,124,124,124,124,124,124,124,123,123,122,122,121,120,120,119,119,119,119,117,115,112,108,105,101,99,98,97,97,97,99,100,102,103,105,107,110,112,114,117,120,124,127,131,136,140,144,147,150,152,153,153,152,151,148,146,142,139,135,131,128,126,
124,123,122,121,122,123,124,126,128,130,131,133,135,137,139,140,141,143,144,145,145,145,145,144,142,140,138,135,131,128,124,120,116,112,108,105,102,101,100,100,102,104,106,110,113,117,121,125,130,135,140,144,148,151,153,153,153,153,153,152,151,150,149,148,148,147,146,145,144,142,140,138,135,132,129,127,125,123,122,121,120,120,119,119,119,118,118,117,117,117,117,117,117,117,117,117,117,117,116,115,
114,113,111,110,109,108,107,106,105,104,103,104,104,106,108,110,113,116,119,122,125,128,130,133,136,139,142,146,150,154,157,159,160,161,160,159,157,154,151,148,145,141,138,135,132,129,127,126,125,124,123,123,123,122,122,123,123,124,126,128,130,133,135,137,139,139,139,138,136,134,132,130,128,126,124,122,120,119,117,116,116,116,116,116,117,117,117,118,119,119,121,122,124,127,130,133,136,139,142,144,
145,146,146,146,146,145,144,144,142,141,139,138,136,134,132,130,128,126,125,124,123,122,121,121,120,120,120,120,120,121,121,121,121,120,120,119,118,117,116,115,113,112,111,110,108,107,106,105,105,105,105,105,106,108,110,113,116,119,122,125,128,131,133,135,138,140,142,144,147,148,150,151,152,153,153,153,153,152,151,150,148,147,145,143,141,139,137,135,133,132,131,129,128,127,126,125,125,124,123,122,
122,122,123,123,124,125,126,127,128,128,128,128,128,127,126,124,123,121,119,118,117,117,117,117,118,119,120,120,121,122,123,124,125,126,128,130,131,133,135,137,140,141,143,144,145,145,145,145,144,142,140,138,136,133,131,128,126,123,121,119,118,116,115,114,113,113,113,113,114,115,116,118,120,123,125,127,129,130,131,131,131,130,128,125,123,119,116,113,110,108,106,105,105,105,105,106,107,108,110,113,
115,119,122,127,131,136,140,144,148,151,153,155,156,157,157,157,157,157,157,157,156,155,153,151,149,147,144,141,139,136,134,131,130,128,127,126,125,125,124,123,122,121,120,118,117,116,115,115,115,116,117,119,121,123,124,125,126,126,125,125,124,122,121,121,120,120,121,121,122,123,123,124,124,124,123,123,123,124,124,125,127,128,131,133,137,140,144,147,149,150,150,150,149,147,144,140,137,133,129,125,
121,118,116,114,112,111,110,109,109,109,109,109,110,111,113,114,116,117,119,120,122,123,125,127,128,129,130,131,131,131,131,130,129,128,126,124,122,121,119,118,118,118,119,120,122,124,127,131,134,137,141,144,146,148,149,150,151,151,151,151,150,149,148,146,145,144,144,143,142,141,140,139,138,137,135,134,132,130,129,127,126,125,124,123,122,121,120,119,118,117,116,115,114,114,113,113,113,113,113,113,
113,113,113,114,115,115,117,118,120,121,123,124,126,127,128,129,129,130,130,130,130,130,130,131,131,132,133,135,136,138,140,142,143,145,145,145,144,143,141,138,135,132,128,124,121,117,114,112,111,110,109,109,110,111,112,114,115,117,118,120,121,123,124,124,125,126,127,127,128,128,129,129,129,128,128,128,128,128,128,128,129,129,129,130,130,131,132,133,134,135,137,139,141,143,144,145,146,147,147,147,
147,147,146,145,145,144,142,141,139,137,135,133,131,129,127,126,124,123,122,121,120,120,120,119,120,120,120,121,121,121,122,122,121,121,120,120,119,119,118,118,118,118,118,118,117,117,116,116,115,115,115,114,115,115,116,117,118,120,121,123,125,127,130,132,134,136,138,140,141,142,143,144,144,144,144,144,144,143,143,142,142,140,139,137,135,132,130,127,124,122,119,117,115,113,112,111,110,110,111,111,
113,114,116,118,120,122,124,125,127,129,130,130,131,131,131,131,131,131,131,132,132,132,132,133,133,133,134,134,135,135,135,136,136,136,137,138,138,139,140,141,141,142,142,142,142,142,141,140,138,136,135,134,133,132,131,131,130,130,129,127,126,124,121,118,116,113,110,108,107,107,107,108,109,111,112,114,116,117,119,120,121,123,124,124,125,126,126,127,126,126,126,126,125,125,124,124,124,123,123,123,
124,124,124,125,126,127,128,130,131,133,135,136,137,139,140,141,141,142,142,142,141,141,140,139,138,137,135,134,132,131,130,129,128,127,126,125,125,124,123,122,121,120,119,118,118,117,117,117,118,118,119,119,120,121,121,122,123,124,125,126,127,129,130,131,133,135,136,137,138,139,140,140,140,140,139,139,138,138,138,138,138,138,139,139,139,139,138,138,137,135,134,132,131,130,129,127,126,125,125,124,
123,122,121,120,120,120,119,118,117,117,116,116,115,114,114,114,114,115,116,117,118,119,120,122,123,124,125,126,127,128,128,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,129,129,130,131,131,133,134,135,136,137,137,137,137,137,137,137,136,135,134,133,131,131,129,128,127,127,126,126,126,126,126,125,125,125,125,125,125,125,126,126,126,127,127,127,127,128,128,129,129,128,128,127,127,127,
126,126,126,126,126,126,126,126,127,127,128,129,130,131,131,132,132,133,133,133,133,133,133,133,132,132,132,132,132,132,132,132,132,132,131,131,131,130,129,129,128,127,126,125,124,123,123,122,122,121,121,121,121,121,121,121,121,121,121,122,122,123,123,124,124,125,126,126,127,127,128,128,129,129,129,130,130,130,131,130,130,131,131,130,130,130,130,130,130,129,129,129,129,129,129,130,130,130,130,130,
130,130,130,130,130,130,130,130,130,130,130,129,129,129,128,128,128,127,127,127,127,127,126,126,126,126,126,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
};
const uint8_t CH[5596] PROGMEM =
{
128,129,128,129,127,128,128,127,130,129,127,128,129,127,128,128,129,126,130,125,132,124,134,121,135,122,134,116,148,104,148,108,146,114,139,117,136,129,123,135,115,146,105,153,103,155,101,154,102,154,105,149,109,144,114,139,122,130,128,125,136,118,139,119,137,118,138,118,138,119,134,124,132,122,131,127,130,126,131,124,132,124,132,124,133,122,135,119,136,119,138,118,138,119,137,118,
137,121,137,119,136,122,132,127,126,129,126,132,122,136,119,136,118,140,113,144,112,146,111,144,110,144,112,144,114,140,116,136,121,133,125,129,128,126,132,122,137,117,143,114,142,111,146,108,148,107,149,108,148,109,144,114,142,118,135,124,130,128,127,132,123,134,118,140,116,140,116,139,117,140,117,137,119,138,119,136,124,124,140,125,107,172,74,179,89,152,114,134,137,104,155,98,164,88,171,87,
160,104,139,131,113,152,100,157,99,155,104,150,110,134,139,100,170,80,176,83,168,94,148,119,128,137,110,154,95,165,92,162,103,143,123,123,139,113,147,108,143,121,127,136,113,148,105,153,103,151,108,142,123,127,135,112,151,102,160,93,163,93,161,102,148,116,133,131,120,140,113,143,113,142,116,136,122,133,126,129,122,136,137,90,175,93,141,147,69,215,34,201,85,140,146,89,167,109,123,149,
109,127,159,72,195,64,171,121,99,183,66,174,114,111,160,95,149,120,126,133,131,108,169,73,182,91,138,152,75,195,61,182,95,140,129,122,137,119,135,116,150,95,171,83,160,118,111,173,64,194,77,163,106,141,117,139,121,124,148,86,187,62,190,84,144,142,89,181,72,175,97,146,121,123,142,107,162,82,182,66,188,79,159,115,124,146,100,162,90,167,89,166,93,154,112,132,138,106,156,97,
155,111,135,132,107,163,86,173,84,166,97,151,112,132,137,107,165,79,182,74,174,97,144,123,125,134,123,131,124,134,119,143,110,141,127,114,155,94,161,102,138,134,112,148,109,142,119,137,110,155,93,167,93,150,121,118,152,99,148,121,125,136,123,125,142,106,149,115,122,150,95,165,99,141,132,110,152,108,141,123,130,120,148,95,169,89,155,123,110,161,90,162,109,130,139,113,140,123,126,132,
130,113,159,86,170,99,133,151,80,189,67,180,93,146,119,136,115,146,113,133,141,93,177,75,175,98,130,169,48,214,69,141,160,66,187,101,113,167,96,121,188,21,255,21,180,144,56,223,50,165,132,101,155,128,88,192,65,161,144,63,217,48,170,138,72,202,60,174,109,127,126,148,91,175,87,139,154,74,198,63,168,112,132,124,139,111,139,136,98,173,77,169,109,124,155,92,165,100,148,111,
146,104,161,98,141,140,94,179,75,165,116,119,147,115,121,152,99,144,138,85,191,72,155,141,76,194,74,156,130,108,146,133,93,181,74,158,138,84,191,69,164,123,107,156,109,125,158,87,164,111,116,162,86,156,125,105,172,82,158,116,125,134,131,115,152,101,143,131,100,174,75,169,126,101,145,149,71,196,75,140,164,68,182,107,114,149,117,123,142,123,106,179,70,166,119,99,180,85,154,117,
134,111,163,81,172,95,145,128,120,144,99,167,83,164,114,120,144,127,115,141,125,105,178,67,184,104,112,176,63,189,82,153,120,137,117,141,117,134,133,108,163,84,179,85,152,130,98,172,86,156,121,129,120,153,88,163,114,108,181,59,194,81,154,112,140,116,137,132,105,172,80,159,121,111,149,120,118,147,124,104,174,73,169,120,101,178,81,160,111,137,112,157,89,167,101,141,127,121,142,100,
169,80,173,109,114,169,83,150,139,88,172,112,109,174,85,136,161,64,200,79,146,136,112,136,134,110,141,127,116,148,111,143,91,205,42,151,178,65,156,139,119,120,114,172,108,75,217,89,91,193,87,140,105,174,101,107,165,119,125,98,193,75,115,190,97,93,185,108,119,117,150,146,54,207,114,84,159,142,115,94,181,114,108,129,179,63,146,153,107,127,111,194,48,160,158,76,146,146,104,145,
108,149,139,64,203,99,97,178,103,142,94,170,106,126,121,162,100,117,172,93,135,116,177,56,180,113,129,123,125,156,85,151,131,136,90,168,134,74,189,99,120,153,113,123,150,92,166,109,105,199,32,207,104,108,157,118,114,155,103,135,148,85,187,75,153,131,110,150,101,164,93,147,133,104,150,118,129,135,121,119,167,62,193,88,128,160,81,170,112,110,161,115,97,184,83,143,135,113,154,88,
166,113,113,152,121,120,126,149,104,132,135,141,85,174,116,110,146,118,140,111,133,147,107,121,166,88,135,153,99,147,119,134,133,113,138,141,98,141,158,75,171,107,140,116,133,134,126,112,152,122,105,158,114,132,111,161,103,124,147,115,135,120,130,148,92,146,152,78,160,144,76,189,75,167,116,104,171,98,118,159,112,107,172,83,168,90,155,125,111,146,122,132,109,156,117,110,154,120,117,140,
132,111,151,95,179,72,146,192,15,193,155,73,126,197,55,158,133,120,145,87,160,138,102,123,163,95,147,120,122,161,70,183,105,123,135,125,132,131,112,134,153,82,167,106,143,107,149,121,113,164,77,175,121,86,181,113,99,162,123,105,162,85,184,74,146,157,88,148,118,149,101,144,123,141,97,159,122,118,128,136,134,101,163,106,131,138,113,151,96,151,129,117,129,146,103,139,145,97,154,110,
146,106,159,98,146,123,125,142,98,156,130,96,157,134,89,169,109,129,137,100,172,98,120,155,113,126,128,144,109,134,129,138,106,144,122,142,100,152,131,92,172,103,130,140,115,135,133,104,162,105,121,168,82,149,139,111,131,132,132,118,135,124,147,90,160,126,113,129,147,112,126,143,108,159,88,154,129,112,145,122,126,121,155,98,138,136,121,124,137,134,109,142,113,173,58,170,140,97,145,123,
136,126,118,126,163,77,160,124,121,141,104,152,112,143,115,119,161,105,116,143,148,81,160,117,153,85,149,147,98,152,100,169,98,124,146,130,92,175,101,119,168,83,159,116,127,142,102,148,132,120,112,167,96,137,128,131,132,116,136,124,146,89,170,100,140,130,113,147,125,116,124,157,98,138,131,129,133,105,152,127,113,123,164,87,151,124,119,156,84,164,120,111,151,123,106,164,99,139,133,106,
165,93,141,139,112,135,118,146,115,132,127,129,133,128,102,170,100,124,155,96,167,87,143,151,96,131,153,99,152,110,134,145,93,157,123,111,146,126,121,125,146,108,131,134,132,118,129,135,130,116,120,162,92,149,115,143,114,137,121,132,131,115,146,115,139,120,122,141,133,97,155,134,97,161,101,152,118,105,176,90,136,141,122,115,149,108,149,102,150,130,101,162,105,145,97,165,120,88,187,110,
95,158,133,111,138,109,164,104,123,156,81,177,95,143,129,114,143,136,93,155,139,78,188,104,108,149,144,93,137,151,97,161,94,146,139,103,138,137,114,127,157,80,161,119,141,104,133,147,120,116,131,155,84,159,128,107,140,127,133,123,117,145,136,96,154,118,127,147,93,165,103,147,116,122,138,139,107,138,137,112,139,120,140,104,160,107,128,145,102,148,123,115,153,108,127,148,106,130,147,107,
142,107,155,117,111,148,131,116,126,141,119,136,110,148,121,126,123,143,112,126,148,105,141,131,114,138,133,114,138,124,126,142,100,150,121,121,137,133,111,141,133,105,155,110,138,127,123,134,130,106,160,119,99,172,103,131,130,123,145,110,131,137,127,111,151,110,139,121,134,127,119,143,111,152,99,152,117,130,136,109,140,135,109,136,141,100,157,109,126,148,97,164,104,125,139,135,105,138,141,110,
142,114,148,103,145,118,147,96,149,140,91,156,114,143,116,127,140,123,120,137,129,114,150,110,134,127,135,121,124,146,100,161,97,151,111,128,162,83,130,161,113,105,170,101,136,117,157,119,80,198,105,107,143,141,106,141,133,119,131,127,137,121,137,94,179,99,119,160,96,140,137,120,129,123,130,143,104,139,132,112,150,121,115,135,132,125,130,125,116,154,104,138,123,118,150,125,104,149,126,119,
138,116,146,105,140,140,108,125,145,132,110,137,134,123,127,130,129,132,109,149,134,87,174,102,133,133,114,141,127,113,157,99,124,166,93,145,113,137,133,119,131,124,131,140,116,129,124,133,132,128,124,126,121,163,85,140,133,125,144,98,146,127,125,121,156,84,161,120,130,123,121,146,120,130,124,141,101,155,123,114,141,126,131,120,133,126,129,122,139,131,104,153,116,132,122,135,118,141,130,98,
163,107,138,120,131,131,129,114,144,125,107,169,86,160,108,134,141,104,135,146,116,118,147,102,156,111,137,117,130,141,114,131,119,144,121,117,144,115,131,139,116,127,142,101,161,108,122,151,96,163,103,124,148,125,104,157,114,129,127,123,153,100,135,137,129,115,139,129,116,142,123,131,120,136,134,123,116,147,123,116,151,109,133,130,135,119,130,128,139,121,118,144,124,122,139,117,128,143,109,137,
138,107,149,109,141,133,101,157,125,114,132,139,116,133,116,155,99,141,128,128,125,115,155,105,132,139,114,126,146,105,144,110,142,145,82,162,127,108,147,115,137,122,128,134,126,114,149,121,126,126,128,133,122,139,100,162,113,125,133,119,146,111,130,141,122,106,163,110,124,136,122,142,105,147,114,140,110,157,109,117,159,107,130,132,126,126,136,114,154,96,133,162,87,146,126,131,139,103,145,123,
134,118,144,110,145,116,135,122,131,126,123,159,81,161,114,140,123,116,143,134,106,144,132,104,159,110,134,126,120,146,111,137,128,126,118,145,127,106,146,129,128,118,134,128,134,108,150,123,110,153,114,136,114,132,136,129,117,128,140,119,131,114,142,125,133,112,150,110,126,149,105,139,124,129,135,116,123,152,98,150,127,110,144,128,125,127,122,142,121,119,138,132,113,136,139,117,121,138,129,129,
125,116,157,102,140,127,122,139,128,115,147,118,118,156,104,138,119,135,138,114,122,144,126,112,150,107,138,130,129,124,123,134,134,121,116,161,94,143,134,122,120,133,137,123,117,132,146,109,128,140,121,125,134,133,116,139,115,142,130,104,160,102,151,117,119,134,148,95,154,119,122,147,99,163,95,142,136,127,114,139,128,124,129,131,126,116,154,111,130,124,137,142,87,161,128,108,143,127,127,124,
126,141,128,98,163,116,123,137,117,139,118,139,113,146,111,143,122,122,139,110,141,130,128,107,161,103,143,113,133,134,120,139,117,128,127,145,108,127,146,119,117,145,117,129,127,128,145,100,127,171,77,152,124,125,141,105,141,135,106,145,133,105,152,105,149,115,132,125,129,138,117,131,127,127,134,122,125,143,104,151,121,108,158,107,138,131,115,140,121,125,148,104,129,154,109,128,126,139,124,123,
130,138,118,124,150,111,122,143,124,130,120,130,134,129,118,142,114,139,126,125,131,123,138,114,152,101,145,128,124,131,129,119,143,118,126,145,89,168,116,113,145,117,138,119,126,141,120,118,151,115,120,136,131,134,101,153,116,136,120,125,144,106,145,125,118,134,135,111,149,110,126,151,97,159,101,136,135,119,125,139,118,128,148,97,150,115,142,117,131,126,138,114,130,147,98,140,140,120,122,127,
141,125,118,128,146,107,133,145,105,140,124,140,111,143,111,152,109,132,139,106,151,123,121,126,142,107,156,102,141,133,112,150,110,130,139,122,125,138,116,131,132,131,123,119,146,125,120,124,140,130,104,154,125,111,141,128,128,121,124,147,121,108,159,103,136,135,121,130,123,137,124,126,121,148,109,140,123,132,114,147,119,123,138,115,146,114,129,128,132,124,138,106,147,128,115,136,131,124,123,138,
128,119,127,133,143,100,137,147,104,138,131,120,135,126,125,147,90,163,119,112,150,113,135,126,131,123,130,120,147,115,125,135,127,131,114,148,102,156,109,130,139,110,140,129,125,128,129,119,158,88,142,142,114,134,122,134,128,122,134,132,118,124,151,105,134,132,124,130,128,125,130,130,119,155,86,161,118,127,130,124,136,120,135,122,139,111,144,119,137,111,139,131,122,141,98,161,118,115,144,119,
131,130,118,145,116,114,161,106,126,138,123,140,109,139,127,123,135,124,132,117,147,118,125,127,144,104,148,119,128,134,109,160,103,132,133,134,113,145,106,146,127,118,138,124,127,129,129,126,137,107,147,133,103,137,140,118,133,114,145,124,116,138,131,108,148,125,121,126,132,132,118,137,120,137,114,144,124,111,138,147,101,137,133,116,149,98,152,125,111,149,121,115,146,112,134,143,97,152,116,138,
123,119,142,130,115,130,140,116,126,136,133,111,137,134,124,128,117,149,117,120,152,101,140,136,126,117,140,122,143,104,140,143,99,150,125,130,112,149,117,136,113,135,141,111,137,123,134,123,135,118,139,126,118,143,121,130,116,145,125,124,123,132,142,103,144,129,118,134,134,114,135,125,128,142,93,165,111,117,156,105,133,127,137,122,125,116,164,97,132,135,125,131,115,149,106,143,117,137,126,120,
128,143,111,137,123,123,152,98,138,144,103,149,117,128,136,111,144,129,114,134,141,107,147,114,133,123,138,120,128,124,134,142,95,155,122,123,129,135,119,133,121,140,126,108,149,125,131,115,139,124,133,122,122,143,123,122,140,120,127,135,115,151,107,126,153,108,131,136,114,147,110,139,128,117,139,131,114,137,129,129,122,131,139,100,155,114,142,107,135,143,118,114,150,120,126,137,107,155,105,141,
128,124,126,134,125,130,127,118,144,127,116,130,136,124,128,128,128,138,108,146,126,109,152,118,129,126,132,123,130,126,134,121,118,155,112,124,125,150,103,139,130,120,140,103,162,107,122,139,138,104,148,112,138,138,101,154,111,139,128,119,130,138,117,133,133,116,131,134,127,123,126,137,123,129,118,147,108,138,140,103,143,127,130,116,139,123,140,103,151,128,102,148,128,128,110,147,121,136,111,139,
133,113,143,126,122,127,141,114,143,111,136,133,121,133,120,131,138,120,123,135,129,126,129,128,123,136,129,124,127,133,124,140,104,156,110,126,146,118,121,138,128,130,123,117,162,93,145,130,127,119,137,128,129,119,133,137,119,131,123,137,117,141,117,125,140,119,131,132,114,142,125,122,136,115,135,137,107,141,125,121,141,120,122,133,134,120,132,113,149,122,112,147,123,120,132,135,115,141,108,156,
112,119,145,116,133,124,136,116,140,117,139,118,133,125,134,125,123,137,111,151,116,118,150,107,142,129,109,146,124,126,137,108,141,142,95,160,108,137,124,132,133,111,139,133,130,108,146,127,129,112,148,117,124,143,111,146,108,142,130,117,136,131,120,135,133,112,143,118,138,123,125,132,129,126,128,133,114,147,122,118,143,114,138,128,128,123,128,132,137,110,127,153,110,132,117,151,104,141,128,124,
128,122,145,116,116,144,133,104,159,103,141,128,117,146,108,132,146,104,136,135,114,139,124,129,130,119,137,128,123,130,125,136,120,136,111,139,137,112,133,133,121,133,128,125,139,103,160,119,109,142,136,119,126,130,129,136,108,152,111,129,137,131,109,144,126,123,136,116,143,116,130,136,123,117,146,121,129,127,128,130,128,125,132,124,132,122,140,117,133,124,128,144,104,135,137,130,112,144,112,152,
103,138,139,102,148,126,125,119,141,122,135,112,142,127,121,138,117,133,120,146,114,124,140,123,130,122,131,134,123,123,144,112,131,137,114,149,110,130,140,120,128,127,133,124,135,113,152,108,131,140,124,119,130,141,114,140,105,158,111,130,134,120,127,139,122,117,143,120,139,112,134,133,123,127,134,124,117,144,123,121,136,118,144,121,117,140,126,122,138,112,141,131,102,159,111,128,129,130,134,118,
124,140,126,113,145,117,133,120,145,111,129,135,124,135,111,143,123,123,134,132,106,154,119,126,124,128,144,116,123,138,127,122,133,125,127,130,130,122,138,115,134,132,126,125,131,123,146,102,138,139,114,134,127,136,117,131,131,138,107,143,124,133,116,140,124,116,155,109,132,126,133,133,116,125,151,105,135,143,103,145,121,136,127,112,146,130,117,129,133,127,131,124,123,137,126,125,127,137,116,138,
121,134,129,106,159,112,127,127,138,114,139,119,135,124,119,151,109,134,127,138,108,149,117,123,139,123,136,111,129,149,113,116,148,121,125,132,116,145,113,135,135,111,138,122,138,116,134,121,138,127,121,126,138,126,117,141,113,150,107,137,136,108,144,127,123,130,132,119,143,111,145,119,120,149,115,127,128,138,119,129,130,131,121,132,134,125,119,135,140,115,124,138,124,139,114,132,135,124,127,128,
126,130,135,114,147,108,137,133,126,119,140,123,133,127,117,147,112,137,129,121,128,141,112,134,128,128,130,118,142,123,120,131,140,118,122,138,129,123,130,124,135,126,121,141,116,125,146,111,138,125,114,155,112,124,134,127,133,129,107,156,112,128,138,114,139,122,139,113,138,122,140,114,137,126,129,120,138,131,104,156,117,130,121,131,136,119,121,148,116,120,143,124,125,129,122,142,118,128,128,130,
127,132,122,124,147,106,146,118,130,126,135,122,128,124,134,136,105,148,116,139,118,136,120,126,144,114,130,126,138,124,122,128,148,101,140,142,106,141,119,139,127,110,150,123,118,140,125,123,132,126,132,126,122,139,118,142,111,141,119,137,128,111,147,122,127,128,130,118,149,107,143,117,129,145,108,133,133,126,123,141,116,129,131,130,130,114,135,143,113,120,149,117,126,134,123,137,114,133,139,111,
135,132,124,130,129,122,133,125,131,126,126,129,128,133,116,143,110,143,127,117,135,130,120,141,117,124,144,110,150,103,135,140,122,117,140,124,130,125,129,133,115,138,129,125,116,142,131,116,132,130,125,132,119,138,123,126,133,128,119,141,119,132,132,120,135,122,136,121,138,113,142,122,129,129,119,138,129,123,122,146,109,145,119,131,128,121,145,118,121,134,143,111,131,130,133,124,126,132,125,130,
126,136,117,128,144,109,141,121,127,135,123,127,133,121,131,139,105,155,106,139,130,123,127,131,126,125,135,116,140,113,143,126,120,124,145,122,114,142,123,133,123,128,136,115,132,139,115,121,147,119,127,127,126,138,116,135,126,127,126,140,114,129,141,116,137,120,132,129,127,124,138,114,136,132,113,147,111,135,128,131,122,129,129,132,120,131,135,119,130,130,138,105,140,138,115,129,128,133,133,111,
145,124,118,146,119,118,141,122,135,118,127,142,115,134,127,128,122,140,122,127,125,137,123,130,125,128,138,113,143,116,134,130,123,128,138,115,129,140,119,131,118,142,125,123,126,141,115,129,142,111,132,132,129,131,115,133,140,111,136,131,116,142,126,119,134,119,148,111,131,129,134,121,127,134,119,135,125,131,120,141,109,155,105,134,136,115,146,112,129,140,119,120,147,110,138,121,131,138,108,139,
134,121,128,128,130,124,137,122,126,129,132,129,120,130,134,129,115,147,109,138,128,127,129,118,138,126,129,112,148,117,135,121,126,135,127,123,130,136,111,145,116,138,121,124,141,122,119,138,127,124,130,127,132,122,132,132,121,129,129,131,123,127,138,109,146,123,124,127,131,133,130,110,144,131,110,148,110,140,126,125,131,127,121,139,124,124,132,119,143,122,124,127,142,120,123,134,127,129,124,132,
131,122,127,144,111,132,136,119,133,129,125,131,122,137,130,114,137,137,114,134,132,121,133,124,136,121,124,132,142,104,141,126,129,132,117,132,131,130,121,135,116,144,113,137,128,124,126,135,130,113,140,128,128,123,129,130,128,121,139,122,119,147,114,126,138,119,136,118,136,131,115,133,140,115,123,139,124,130,115,144,118,132,125,132,127,118,146,116,133,122,134,126,137,110,139,130,123,134,112,145,
123,126,128,133,121,134,131,121,130,130,129,129,122,134,129,122,133,134,107,148,125,121,133,121,143,112,132,133,131,111,145,124,126,123,132,135,120,131,120,145,113,135,128,122,138,123,124,137,119,129,141,111,138,124,128,138,110,136,134,121,132,127,124,131,131,123,128,128,133,126,123,131,133,118,128,144,109,136,126,133,126,119,136,132,118,129,136,118,137,120,136,121,130,124,136,124,121,136,124,133,
123,122,135,130,116,142,116,131,134,120,133,122,131,136,116,133,132,124,130,130,126,123,133,133,119,125,136,128,130,112,149,121,119,141,123,129,126,128,132,128,114,148,114,136,127,121,137,124,129,123,137,118,138,121,133,122,129,133,129,120,128,139,115,136,126,124,134,128,128,124,126,139,125,118,133,138,110,141,126,128,122,134,129,126,118,136,141,100,151,117,134,126,129,127,133,119,136,130,117,146,
110,140,126,125,126,132,129,124,129,127,131,126,129,127,127,127,136,123,121,144,118,128,135,117,137,120,137,128,114,136,143,108,132,136,122,134,113,146,117,129,130,133,116,132,134,123,129,124,135,121,137,118,135,122,132,130,121,132,130,123,131,129,122,134,127,128,129,124,129,131,125,132,123,125,137,127,114,143,123,129,127,125,136,118,129,137,120,120,144,121,130,119,136,129,123,131,126,134,120,136,
123,126,131,133,116,140,118,130,137,112,145,116,129,137,119,129,135,115,142,123,121,138,122,132,125,126,134,123,129,133,128,120,133,137,116,131,128,133,123,127,125,139,111,140,126,117,141,121,134,121,132,124,137,116,136,124,126,136,122,127,129,132,119,139,115,136,131,119,137,120,131,132,120,133,130,119,134,133,122,128,125,139,120,124,135,124,131,117,146,113,128,137,125,124,128,129,132,125,118,147,
105,146,123,123,132,128,130,126,126,130,133,119,136,122,130,127,131,124,127,133,123,134,127,120,138,123,132,123,127,136,126,120,139,126,118,139,124,132,116,138,128,127,118,139,128,118,143,120,127,131,132,124,130,120,143,119,123,142,115,133,131,125,125,130,129,133,119,129,133,125,127,128,127,128,133,122,128,134,120,132,131,122,133,121,136,129,116,134,138,112,138,125,129,128,125,137,121,125,134,133,
113,140,123,130,126,133,123,127,131,129,129,115,143,125,124,129,132,124,131,127,128,130,122,137,125,124,130,128,130,128,125,126,137,123,123,135,124,130,125,130,129,125,125,141,116,125,141,117,138,117,137,123,130,128,133,119,132,135,117,133,124,138,114,140,121,131,124,128,137,118,127,137,125,124,133,119,140,123,121,139,121,131,130,122,137,119,132,132,128,117,140,126,127,127,127,133,123,131,124,135,
114,147,119,125,134,125,129,126,132,125,131,121,142,115,128,136,129,122,129,132,125,132,119,136,128,121,137,124,124,136,119,137,128,116,138,131,121,134,119,140,123,122,138,122,128,128,135,118,131,128,133,119,136,123,134,124,127,136,109,144,129,119,130,133,124,133,116,140,124,120,141,123,125,129,132,128,126,124,131,130,126,126,129,128,130,126,126,134,125,124,138,121,126,131,130,129,120,133,130,127,
122,137,122,128,135,125,122,132,131,122,133,119,144,112,133,138,114,129,135,126,124,126,129,140,109,138,127,126,129,127,130,124,131,127,129,129,123,131,132,125,128,126,131,135,113,135,135,114,143,117,133,126,127,134,126,120,138,127,120,143,116,134,124,135,121,126,131,133,124,119,143,120,127,129,133,120,130,129,131,126,121,139,124,125,129,127,129,129,125,127,134,124,130,130,122,134,123,133,127,125,
126,139,118,132,129,122,137,120,133,122,131,129,131,117,137,126,125,129,128,130,121,136,126,127,123,132,133,121,126,136,123,129,129,124,133,125,127,135,119,133,128,125,132,122,129,133,126,124,132,124,132,124,130,128,129,129,128,128,123,137,122,129,130,127,125,134,126,129,125,128,138,116,130,132,128,124,132,126,129,126,129,131,123,128,133,127,125,131,124,132,129,122,133,127,128,131,122,134,126,126,
131,128,123,134,126,128,128,127,132,124,133,123,131,124,134,125,123,134,129,123,130,131,124,132,122,138,121,125,138,124,126,128,130,128,128,125,132,125,129,130,126,128,128,130,126,130,126,126,133,123,130,126,129,130,124,129,129,128,127,132,121,134,126,130,124,130,129,125,130,126,133,121,133,130,125,125,134,125,128,127,129,132,121,133,128,124,130,129,128,127,127,130,128,128,128,128,128,130,127,127,
127,132,124,130,129,125,133,124,130,127,127,129,129,124,132,125,128,132,123,130,127,131,125,128,128,131,124,128,131,125,127,130,128,125,129,127,131,124,128,131,126,128,130,126,129,128,128,128,128,128,129,127,128,129,127,129,129,127,126,131,125,131,126,128,130,127,128,128,127,130,129,125,132,125,129,128,128,127,127,129,129,127,127,131,127,128,127,130,126,129,129,127,129,127,129,128,127,129,128,127,
129,127,127,129,127,129,128,127,130,127,128,128,128,128,129,127,128,129,127,129,128,128,127,129,127,129,126,129,129,126,129,128,128,127,129,127,128,127,129,128,127,128,128,128,128,129,127,128,128,127,129,127,129,128,127,129,128,128,128,128,127,129,127,129,128,128,128,128,128,128,128,128,129,128,128,128,128,128,128,128,128,128,128,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128
};
const uint8_t QU[6502] PROGMEM =
{
128,126,128,128,128,128,128,128,128,134,131,128,129,128,127,128,130,129,126,128,127,132,128,127,128,126,129,130,125,132,128,127,128,136,128,127,117,125,126,147,138,123,113,116,115,184,113,139,127,60,158,146,154,133,131,36,163,136,132,221,50,114,136,76,169,203,96,86,192,1,208,147,101,177,129,19,183,136,113,205,90,71,173,79,139,205,68,135,145,108,132,136,93,147,144,128,
137,122,109,127,137,128,135,135,119,130,124,114,140,142,107,139,128,112,141,137,109,151,114,125,136,113,125,149,121,126,147,96,127,146,117,136,146,99,135,128,112,147,144,100,147,118,105,162,127,122,145,103,112,152,118,141,141,102,122,139,116,146,134,113,130,123,121,147,130,123,122,124,122,144,130,128,124,111,129,130,146,151,132,81,140,105,141,198,85,121,112,73,187,193,80,160,70,68,209,134,
161,141,59,83,160,137,175,157,73,105,121,128,164,153,130,107,95,102,146,191,124,131,102,62,155,155,151,158,98,85,140,126,154,160,103,104,119,122,153,153,130,104,117,114,140,153,127,127,120,100,133,150,129,147,120,98,128,136,136,140,137,106,123,124,121,155,133,121,125,116,117,149,133,130,134,113,116,139,129,132,141,113,127,119,134,129,142,119,123,123,136,104,158,135,118,149,61,174,105,155,
148,138,81,116,150,89,232,65,127,121,94,161,160,138,89,146,60,173,156,105,179,77,121,131,126,136,165,119,89,160,72,164,140,119,145,131,97,142,115,111,177,113,130,120,122,118,156,120,135,135,88,141,139,137,129,126,111,128,133,128,152,117,122,124,126,126,141,127,115,141,114,128,129,138,128,128,124,116,141,123,138,125,120,128,126,134,137,132,116,129,123,116,150,123,120,135,129,110,155,93,
148,166,69,165,126,90,147,146,123,166,89,97,159,113,138,188,82,98,128,101,202,137,111,102,104,139,160,153,97,140,95,107,182,100,158,127,96,143,112,144,126,134,126,128,116,123,134,137,136,123,120,123,122,144,126,143,120,115,135,125,134,123,123,135,133,114,138,121,137,131,111,142,123,133,128,117,147,111,127,139,116,146,120,118,134,124,133,133,124,124,130,124,131,126,136,126,132,110,146,117,
122,156,105,143,120,125,134,125,128,134,120,118,135,126,125,151,126,120,127,94,145,149,131,129,113,102,136,153,141,141,95,106,142,128,153,123,121,102,126,128,150,153,113,125,98,132,134,136,147,135,104,121,115,134,161,113,134,132,85,141,143,125,163,101,112,132,118,150,149,109,127,110,117,149,138,134,120,109,122,132,141,134,126,126,114,133,126,134,137,117,126,124,128,140,128,133,120,122,124,131,
139,131,129,119,123,128,124,143,132,125,125,113,122,157,132,94,155,99,117,173,134,90,151,107,120,170,83,152,133,86,168,129,111,151,104,114,179,97,120,174,80,127,156,112,145,129,107,118,127,145,160,112,114,110,115,164,134,136,113,97,146,117,155,137,117,119,122,107,146,149,120,154,95,110,132,132,156,135,114,112,121,121,147,148,125,116,118,119,131,149,134,124,118,115,132,133,141,132,116,120,
120,129,150,133,125,117,116,123,149,122,144,125,102,146,113,147,134,120,120,138,106,124,145,114,131,145,119,129,128,109,132,153,102,140,133,88,162,146,114,151,100,88,182,110,124,183,68,137,140,109,134,167,85,138,136,94,167,128,126,118,138,112,131,131,136,132,123,118,134,128,118,143,127,124,135,121,115,140,124,125,150,110,126,129,122,142,134,117,130,121,119,139,140,127,124,125,108,141,142,122,
137,120,111,144,123,127,143,113,122,143,110,136,139,106,144,134,114,140,113,119,155,116,131,130,117,131,151,115,119,115,125,156,131,122,108,123,128,152,129,142,96,108,149,150,111,147,125,90,145,121,151,146,99,142,111,111,152,147,108,146,117,107,135,122,143,148,110,131,123,92,158,139,130,137,116,97,151,118,142,155,99,124,125,116,158,127,129,136,91,139,133,126,147,120,118,124,126,135,140,123,
127,115,130,129,141,132,128,122,112,128,139,137,135,124,104,136,128,129,146,112,132,112,128,143,125,131,132,118,114,149,97,182,101,122,121,116,123,167,156,62,180,28,195,174,86,162,74,111,137,205,76,186,82,76,190,85,167,152,110,103,125,116,138,183,116,116,118,91,133,168,140,120,130,91,124,168,114,155,128,80,142,135,126,154,122,97,140,119,127,165,118,117,130,102,137,152,126,122,135,105,
127,146,114,146,136,105,128,130,115,151,141,105,141,107,115,159,125,131,139,101,123,141,125,143,136,113,120,132,130,126,138,117,132,125,125,122,150,128,128,135,87,117,171,131,123,136,84,131,156,119,166,124,55,165,127,123,178,125,82,120,105,153,181,124,105,124,81,141,185,126,130,103,85,147,157,153,132,111,90,133,149,124,151,118,106,141,123,127,141,128,124,136,111,124,144,123,132,133,118,123,
136,131,129,128,115,132,128,132,134,125,121,129,129,136,127,131,115,135,124,130,136,121,130,126,124,133,130,127,131,121,130,131,123,137,124,129,114,142,124,126,135,125,133,108,148,100,151,142,104,141,95,135,140,176,93,124,98,121,176,136,125,88,120,121,195,114,131,113,98,124,149,156,119,146,88,126,125,138,155,117,127,105,150,101,150,137,124,127,117,136,119,129,141,133,128,110,120,131,136,132,
151,109,109,143,125,135,128,121,123,135,124,144,120,117,128,136,119,136,131,120,133,119,139,131,119,134,123,130,131,132,125,129,121,130,136,115,144,131,110,130,130,127,141,117,125,132,112,143,137,124,133,128,93,135,141,130,157,93,111,146,113,165,148,98,89,133,140,158,137,117,128,81,129,175,125,151,106,114,111,120,169,135,130,126,95,118,143,134,157,139,94,128,97,133,172,117,146,117,84,148,
139,125,161,102,116,131,105,158,150,110,135,101,116,158,127,126,134,106,121,137,130,147,121,119,123,125,137,135,131,120,124,117,138,134,137,123,121,120,128,135,136,123,125,125,124,135,134,128,127,120,129,132,128,129,132,114,132,127,129,133,139,104,139,123,89,190,129,104,164,65,122,174,129,130,148,48,128,203,86,189,104,71,136,151,128,186,83,98,156,97,131,167,93,134,161,111,123,145,67,168,
149,110,132,135,96,145,141,111,147,125,105,153,127,112,140,123,123,155,120,108,131,115,143,144,128,113,138,102,134,146,117,138,135,106,142,129,101,144,139,119,149,118,110,134,121,136,147,114,124,129,118,138,142,112,132,127,114,147,123,125,127,129,139,122,132,113,112,141,142,147,106,110,118,154,144,124,136,89,120,137,174,127,117,120,80,149,163,120,160,99,88,153,126,128,170,108,108,150,84,146,
160,109,156,114,95,142,119,146,158,87,137,116,118,160,127,124,131,109,124,151,120,135,124,117,131,133,129,133,129,116,129,134,126,137,128,121,129,121,131,133,129,131,119,129,130,123,137,130,118,135,122,127,135,128,126,130,122,129,130,128,126,131,127,128,124,135,115,130,151,96,163,97,142,124,123,120,144,131,109,169,98,133,107,139,160,112,131,90,128,125,182,120,135,91,101,150,139,162,128,113,
91,129,126,159,149,126,108,104,114,154,144,139,143,100,90,141,129,152,155,102,111,124,116,161,154,108,116,115,112,160,137,129,129,102,116,157,123,145,131,100,128,125,135,143,131,116,132,115,127,136,143,127,126,113,117,133,135,139,130,125,112,125,135,141,137,119,119,117,129,135,145,126,117,112,139,133,140,146,95,114,134,119,176,135,76,142,102,140,172,124,113,108,106,160,161,114,130,95,98,169,
144,137,141,80,112,156,126,144,142,91,134,133,105,152,136,115,148,110,101,162,121,133,146,100,132,123,119,158,120,129,127,112,136,137,126,131,120,120,135,128,136,131,119,122,132,124,137,131,126,126,125,120,136,134,129,126,121,126,128,138,130,123,123,119,129,142,131,128,122,113,132,133,139,124,128,107,147,106,157,133,102,159,77,155,120,148,123,146,113,58,214,74,200,120,75,118,136,135,177,152,
27,143,106,174,185,111,80,117,108,150,206,86,131,88,97,159,157,140,129,110,103,138,129,137,140,133,111,122,117,130,152,136,110,123,115,127,148,147,112,133,99,120,161,124,136,131,96,126,147,123,151,118,107,134,131,132,141,127,107,133,120,135,141,128,128,122,113,126,147,120,146,120,117,123,125,139,144,127,114,124,125,130,141,132,116,127,118,126,148,124,135,125,101,140,120,142,141,100,135,145,
97,161,139,88,143,128,133,142,107,138,127,116,138,138,118,115,137,134,123,128,124,128,136,128,127,125,121,129,149,114,136,122,108,152,123,127,145,95,148,137,114,145,113,118,138,124,137,133,118,125,128,127,134,134,123,115,132,127,130,144,119,123,124,121,140,135,123,128,119,125,133,137,131,128,124,118,133,132,130,136,117,122,129,124,138,131,128,124,122,130,119,149,118,137,119,123,137,127,141,115,
133,95,151,127,167,114,102,122,114,163,134,142,99,106,124,139,163,131,116,96,140,112,145,151,126,121,114,110,141,134,141,157,99,105,117,141,141,161,114,122,109,97,155,147,129,131,111,117,133,143,124,142,115,110,135,131,137,139,122,115,119,128,131,147,129,116,128,116,131,144,125,141,119,109,132,130,135,128,133,119,122,124,137,133,135,121,125,124,123,142,132,133,120,109,139,127,133,133,121,123,
136,128,123,143,113,112,154,124,126,129,113,134,142,135,111,142,88,148,145,139,125,98,115,142,146,134,138,98,108,153,132,150,121,99,139,121,141,134,132,114,116,148,121,137,130,125,122,131,115,131,144,116,148,120,99,145,122,132,155,107,116,136,112,143,151,109,140,123,103,145,127,126,147,121,118,135,113,136,142,117,135,121,117,136,134,126,137,112,128,131,131,129,137,125,119,128,120,135,134,130,
116,140,103,150,121,136,137,110,138,113,140,142,100,149,88,162,118,142,137,85,153,107,173,119,129,94,113,163,131,150,129,88,122,139,132,158,131,97,138,97,147,138,147,111,140,106,123,151,113,139,143,102,123,133,122,141,134,117,123,128,116,154,131,113,133,122,118,153,118,126,140,107,133,144,115,136,124,117,134,141,122,132,113,123,140,130,130,135,114,124,132,131,133,131,125,122,131,126,138,120,
131,127,128,127,128,130,128,123,139,119,127,133,118,141,145,94,138,132,98,167,142,89,168,84,91,210,114,115,168,51,121,198,75,196,141,10,185,125,107,223,83,102,154,74,145,186,81,156,147,44,172,133,105,178,109,116,137,89,152,154,123,123,124,111,130,141,139,119,124,119,126,144,130,127,125,117,129,137,131,128,134,116,116,137,127,138,130,121,124,130,119,137,132,129,127,123,122,132,129,138,
123,123,126,127,122,137,133,122,129,124,123,139,122,131,136,102,138,128,130,145,124,97,151,98,143,171,78,152,128,96,175,121,105,147,111,109,182,94,108,186,58,169,156,56,170,134,92,176,133,67,186,98,98,199,93,123,151,103,128,168,81,143,156,80,149,144,94,151,143,95,155,115,97,169,127,117,146,111,105,147,129,135,150,98,127,133,121,139,144,118,116,133,118,135,140,123,130,128,115,128,
140,119,135,135,105,137,136,108,158,124,106,145,111,128,157,110,129,138,97,147,143,114,144,117,102,153,125,143,141,90,123,133,141,146,120,107,124,124,143,165,121,83,137,114,161,144,120,124,98,131,138,149,137,112,132,102,133,131,133,147,116,137,108,112,144,135,156,119,106,125,114,148,143,135,113,115,122,132,149,128,123,118,119,134,134,131,132,121,117,132,131,138,129,123,125,114,134,136,128,140,
112,125,122,132,137,131,129,121,120,128,131,135,131,127,122,121,131,136,127,134,117,124,124,136,129,135,123,117,131,130,133,125,139,108,147,110,129,139,120,123,121,151,124,145,117,116,124,131,144,123,142,77,156,124,139,160,106,112,116,128,133,171,109,115,126,103,144,149,128,133,133,90,143,120,137,143,130,121,119,125,118,159,120,129,117,117,128,141,144,124,120,111,140,115,148,135,118,131,109,139,
138,129,124,129,114,131,133,133,137,120,120,127,126,135,135,128,122,119,124,136,127,137,135,106,131,131,124,140,139,114,128,122,122,145,129,122,130,122,128,135,125,133,111,145,133,124,138,101,121,154,120,142,133,94,122,154,117,153,133,80,150,116,122,178,101,120,139,102,142,139,112,149,120,114,144,111,122,154,127,132,132,94,138,132,133,148,115,114,131,127,141,133,121,124,120,130,139,123,130,126,
122,131,130,129,131,123,125,134,122,132,134,124,129,126,122,133,132,127,130,116,131,132,128,133,123,126,124,129,133,134,126,123,128,125,131,134,129,119,136,119,128,139,114,141,122,133,122,126,130,121,142,110,136,122,131,142,124,119,139,111,140,131,118,135,116,146,119,133,119,131,131,133,135,99,144,124,142,146,94,129,119,137,145,148,111,115,117,108,176,122,124,142,86,134,139,139,131,145,95,126,
138,108,161,135,113,135,114,111,150,132,127,137,114,116,139,130,134,139,113,119,129,131,139,136,118,122,123,121,140,138,131,116,122,118,136,144,130,125,123,117,132,137,130,126,126,116,128,139,124,133,134,114,124,142,113,128,143,116,148,110,115,135,126,151,131,110,122,120,135,151,142,100,107,151,111,163,111,134,127,106,152,123,131,120,133,132,120,126,128,130,136,125,138,104,123,142,131,140,123,106,
134,133,131,144,114,116,131,124,143,131,119,130,123,129,138,125,128,130,127,118,137,120,129,138,119,133,122,122,134,135,127,136,115,125,129,129,136,133,119,127,129,121,140,131,124,129,119,129,131,134,123,129,123,135,112,141,134,117,145,112,121,138,135,112,159,90,124,169,104,138,136,90,143,156,96,155,111,96,171,127,130,124,119,107,161,114,142,133,108,135,129,120,137,133,130,130,128,111,134,135,
139,139,100,119,124,143,152,126,113,111,127,129,166,119,121,122,100,143,144,137,130,120,100,130,137,140,137,125,119,113,130,140,130,142,125,109,126,125,138,140,127,117,126,122,135,135,124,135,122,118,133,134,129,136,121,117,138,121,131,144,115,119,145,109,136,144,103,132,145,96,157,135,83,175,106,117,160,111,116,146,103,144,154,99,135,128,106,155,138,115,139,106,111,157,137,120,135,115,105,152,
127,127,150,108,119,139,111,141,141,112,148,110,117,146,128,133,135,114,119,127,134,137,138,115,121,124,123,140,140,123,124,121,123,137,132,135,122,124,119,127,142,126,133,123,117,133,126,134,140,119,122,125,128,135,138,120,126,121,123,135,135,126,134,110,133,128,133,134,123,125,118,139,123,147,109,136,121,128,124,133,138,129,130,108,132,119,150,120,127,121,115,135,133,155,119,115,132,100,150,140,
127,135,113,106,144,146,119,146,97,137,138,114,141,123,123,125,151,102,144,118,118,149,125,129,125,126,107,155,124,124,137,113,133,129,130,124,145,108,135,138,112,134,126,127,130,135,114,141,120,124,142,116,130,133,124,131,126,126,123,134,131,128,130,120,126,135,130,127,132,116,122,136,126,136,133,113,125,127,129,151,135,99,129,119,127,156,146,96,128,105,133,173,123,116,127,90,120,192,122,116,
134,81,137,163,116,159,108,82,157,135,120,158,116,102,146,111,135,151,108,140,123,112,134,134,132,134,123,116,123,131,140,141,123,114,118,128,132,147,132,113,124,123,129,143,133,123,126,114,128,144,125,133,129,114,126,136,123,141,127,120,125,127,127,140,134,118,128,121,126,137,135,129,121,120,128,133,133,140,114,127,113,136,150,115,139,110,116,138,143,117,156,86,113,161,108,160,128,102,127,140,
110,159,124,111,140,129,114,154,109,127,143,99,138,142,117,143,133,105,140,129,118,147,123,113,142,113,124,153,118,129,129,115,128,146,115,136,130,115,137,133,124,132,128,111,143,124,134,129,124,123,127,133,124,140,120,122,132,128,131,134,123,124,134,117,136,133,124,128,124,127,133,131,128,129,123,125,135,130,126,130,118,126,139,126,128,125,119,131,141,127,130,111,127,134,130,144,121,120,120,120,
143,150,111,131,120,111,142,138,137,127,114,111,140,125,145,144,113,122,115,122,152,128,141,120,109,132,115,147,141,128,131,104,122,133,132,148,126,116,120,116,138,143,138,121,120,115,125,144,135,130,128,108,127,135,131,144,121,116,127,125,131,144,126,128,117,119,135,137,135,123,121,120,133,133,137,127,116,125,122,136,135,131,120,128,122,133,129,132,125,130,121,141,115,134,140,98,158,115,123,147,
103,140,147,103,123,154,103,154,130,89,158,105,137,155,110,114,132,128,146,141,110,113,128,127,138,157,114,92,152,108,147,162,99,124,126,101,152,151,100,152,122,91,159,133,120,156,99,110,152,111,139,151,112,113,142,97,149,155,102,144,119,109,137,140,118,151,119,106,142,118,128,148,126,116,141,108,128,148,113,141,127,111,136,130,124,141,121,117,135,123,135,135,121,125,129,123,135,131,122,134,
127,115,137,126,123,144,115,114,152,119,121,155,93,145,131,103,159,120,113,155,118,114,137,118,133,152,103,136,133,90,164,131,115,150,92,138,142,118,147,118,116,133,130,130,137,124,119,129,125,125,142,117,133,133,119,131,124,126,137,122,131,127,124,136,123,130,134,116,135,125,124,140,120,127,133,126,128,130,126,126,132,125,129,132,123,130,130,124,130,127,125,137,122,130,130,119,132,129,128,129,
128,125,121,137,133,113,153,105,133,129,127,131,135,126,111,146,104,137,147,120,127,121,123,127,153,116,129,132,95,148,143,127,132,112,116,143,122,138,146,105,123,128,130,133,143,109,138,120,120,136,134,130,113,143,106,152,118,129,137,113,133,131,128,127,133,117,141,118,130,137,120,129,131,129,124,125,129,133,130,122,131,127,121,137,130,126,130,115,132,133,126,136,126,119,132,125,133,134,127,123,
127,124,133,134,127,127,119,129,131,132,131,126,118,134,132,129,122,128,124,132,137,124,113,139,118,128,160,105,119,149,98,145,143,109,146,108,122,155,118,113,155,116,117,155,104,128,144,114,144,123,108,142,122,134,139,128,116,126,133,120,142,131,120,129,120,121,148,124,128,132,117,124,137,127,131,134,116,128,127,122,144,133,117,133,121,121,143,127,131,125,120,126,133,131,132,127,119,125,134,132,
130,129,122,127,128,129,134,127,124,127,127,129,132,129,122,129,133,122,128,135,120,134,135,112,138,113,123,151,129,117,131,120,117,163,114,130,126,102,138,153,117,125,137,101,153,124,121,143,112,122,146,129,114,146,107,132,146,114,137,127,113,134,136,126,133,131,109,137,127,131,131,125,125,128,128,133,132,115,141,120,130,131,118,139,120,129,138,121,125,130,125,133,132,120,135,124,123,130,132,127,
130,126,124,131,124,128,134,128,128,127,121,133,129,127,132,125,129,130,124,131,127,124,132,130,130,129,128,124,130,132,121,131,124,123,142,120,120,148,112,129,142,108,130,142,118,133,143,95,150,118,120,157,116,123,133,114,128,149,121,126,127,118,134,134,126,136,121,128,125,125,134,126,142,116,130,125,126,129,140,122,127,129,111,145,124,126,135,116,132,135,118,140,125,122,131,124,131,130,127,126,
134,124,130,127,130,128,130,122,129,131,125,138,122,126,125,131,124,137,129,123,128,125,130,132,129,127,128,126,135,116,132,137,113,144,120,129,122,127,133,123,154,95,133,137,125,141,114,145,95,155,117,127,144,96,146,126,141,98,155,112,123,157,98,150,120,110,147,133,108,146,127,103,160,116,120,149,109,133,141,118,117,146,115,129,145,109,137,125,121,137,139,117,134,123,113,147,125,128,133,119,
130,132,123,132,131,119,132,137,117,131,128,122,131,133,125,124,132,123,131,134,124,133,124,126,126,134,126,132,127,127,131,121,128,129,123,136,131,123,125,123,131,139,128,116,133,110,147,138,117,140,104,118,158,120,132,125,113,139,133,126,143,109,111,152,125,135,139,95,139,138,118,149,114,117,138,128,126,137,119,129,133,126,126,130,123,130,131,128,127,129,121,136,128,125,129,126,126,133,125,128,
131,122,128,130,129,126,128,130,128,130,124,128,127,126,133,125,126,130,126,127,131,129,127,127,128,127,132,128,124,128,129,127,130,129,126,131,125,128,128,127,134,121,122,144,112,132,139,112,140,128,109,140,133,120,139,124,110,148,122,127,144,100,132,138,114,144,128,113,136,138,111,141,134,106,145,125,123,139,119,125,128,137,126,131,128,115,134,128,131,131,127,121,124,128,138,133,118,127,124,135,
131,133,123,120,125,132,138,127,125,119,134,124,136,134,116,133,119,133,129,129,127,129,126,128,132,125,130,126,129,135,118,128,131,126,133,130,121,130,126,130,131,128,129,128,118,134,135,119,137,124,117,137,130,125,134,119,121,135,131,137,121,125,131,117,139,128,125,134,119,135,127,118,145,123,121,133,127,116,151,122,120,144,102,137,145,113,138,129,112,142,129,121,141,119,121,137,118,131,140,120,
130,129,121,129,133,126,133,127,119,137,125,126,133,126,125,130,130,127,127,132,121,132,129,121,138,123,128,132,122,128,132,124,131,129,123,130,129,127,129,129,122,128,129,127,130,129,126,127,130,127,131,121,136,130,122,130,131,117,146,124,118,135,104,146,133,129,132,114,107,157,129,131,137,97,130,136,141,127,141,93,126,142,134,135,124,116,120,146,115,140,131,107,140,146,99,154,106,117,163,114,
123,132,116,121,166,105,134,134,94,148,133,123,142,122,109,146,119,130,139,120,127,128,126,125,142,125,127,130,117,129,135,123,139,125,120,128,129,130,134,127,124,129,122,132,132,129,130,124,122,130,130,132,126,127,130,123,134,124,128,132,122,128,138,120,124,139,118,137,130,118,127,126,128,140,134,117,130,118,127,142,134,120,115,125,128,142,140,121,116,123,125,144,136,123,127,107,134,145,126,127,
128,114,136,125,132,138,119,128,132,118,132,132,117,150,121,121,133,119,133,140,123,126,124,116,141,131,127,136,113,121,139,127,133,131,120,124,130,127,134,131,122,129,121,128,134,129,129,131,119,127,131,128,134,127,126,124,126,129,131,130,128,126,122,131,124,141,119,132,130,112,142,123,134,126,132,119,123,135,114,147,126,115,146,111,137,131,131,122,127,124,120,152,103,145,124,123,133,128,133,123,
132,115,140,126,122,144,117,121,138,125,131,134,116,130,129,112,147,135,111,138,119,127,141,127,125,139,104,129,144,119,137,129,114,131,132,124,138,129,118,137,125,121,136,126,124,136,126,127,129,124,126,135,126,128,131,120,134,129,128,128,126,126,131,129,130,127,122,129,130,130,131,125,126,125,127,130,135,127,127,126,122,135,131,119,138,122,122,140,118,127,147,106,139,130,117,132,125,139,124,131,
125,127,127,120,148,119,131,125,117,139,116,146,130,110,142,113,132,140,118,142,117,124,129,130,120,144,120,125,137,115,138,130,123,133,126,118,138,128,123,139,118,126,133,120,139,132,117,135,123,123,138,126,130,127,122,131,127,129,131,127,128,124,129,125,133,129,127,128,123,127,131,127,131,127,125,125,129,131,130,131,115,137,120,129,142,116,132,128,123,124,144,109,137,134,96,164,122,122,139,115,
116,151,125,116,151,89,138,151,118,132,134,103,131,144,110,163,111,106,151,112,134,148,117,118,142,111,137,145,102,147,119,116,140,128,129,132,128,116,141,121,131,136,118,119,139,121,131,142,113,129,125,123,136,139,123,126,121,121,138,136,125,133,121,119,132,132,128,138,121,120,133,119,136,134,125,130,124,122,128,135,129,131,127,119,126,132,127,137,127,116,137,120,128,144,119,124,135,109,142,137,
107,144,125,106,154,129,109,149,111,124,149,115,131,136,105,135,150,108,145,124,106,146,126,121,145,120,121,135,121,126,142,122,127,138,106,137,133,123,142,120,123,129,126,133,136,121,130,127,120,136,130,124,132,121,127,134,128,129,126,127,125,130,130,129,127,125,128,127,130,132,126,128,126,124,131,129,133,127,123,128,125,131,132,129,126,125,125,131,130,133,124,129,122,129,138,117,138,120,129,129,
129,119,140,126,115,146,110,132,136,122,135,125,116,137,134,125,135,118,128,134,130,130,131,116,126,129,139,128,133,114,125,133,126,144,118,122,127,131,128,136,123,124,131,121,139,127,126,125,130,120,144,118,127,139,114,137,129,121,130,131,122,139,123,119,132,128,132,134,120,127,129,124,137,126,127,124,128,129,128,132,124,127,128,126,132,127,126,128,126,130,129,126,128,128,127,128,129,125,127,131,
124,130,133,121,129,132,119,135,133,120,138,114,126,140,119,137,129,116,132,130,122,144,128,114,137,114,131,145,120,136,118,118,139,127,132,136,120,118,136,121,138,134,115,137,117,127,138,125,131,129,120,127,133,128,134,127,122,127,125,132,134,127,127,124,125,131,130,131,129,125,125,128,131,132,127,128,125,124,131,129,130,129,127,125,128,129,129,130,129,125,126,127,130,131,128,128,125,126,128,130,
128,134,120,124,133,126,130,135,122,123,134,118,136,132,119,134,125,123,127,138,124,134,132,111,136,122,133,134,133,112,127,131,125,150,115,127,125,122,129,141,126,119,139,109,139,129,130,128,131,119,131,131,116,141,126,126,129,125,126,130,129,127,136,121,126,131,124,132,130,124,129,126,127,132,128,127,131,123,127,132,127,132,125,128,126,128,127,132,127,129,125,127,129,128,130,126,128,128,125,131,
130,127,132,123,128,129,126,132,128,124,129,127,126,137,122,128,130,119,138,128,126,133,118,126,139,120,134,133,111,136,128,126,141,118,125,135,116,139,133,122,133,121,125,135,124,135,129,117,134,125,123,141,123,126,134,112,138,131,125,138,119,125,130,126,135,132,124,126,126,126,133,131,127,128,126,123,131,130,130,130,123,127,130,126,133,129,127,127,125,127,132,130,127,127,124,128,129,130,129,128,
126,127,128,128,130,128,127,128,127,128,130,128,129,126,127,128,129,132,125,127,129,124,132,127,126,131,121,128,135,126,127,129,126,130,131,127,126,127,125,131,133,128,124,127,127,131,132,123,131,124,122,138,127,128,133,117,129,133,122,137,129,123,128,125,128,133,129,126,129,123,129,131,128,132,127,122,132,126,128,133,125,129,127,124,129,131,128,131,127,124,128,128,131,129,128,126,126,126,130,132,
128,127,126,125,129,130,128,129,126,126,128,129,130,129,127,128,125,128,130,129,128,127,127,126,131,129,129,127,126,130,129,128,127,129,124,131,130,129,128,126,126,128,133,127,126,130,122,128,133,128,130,124,126,130,128,131,128,126,124,131,128,128,131,128,127,128,125,129,131,127,132,123,126,130,127,130,131,127,125,127,128,130,131,126,126,127,127,129,131,127,127,125,126,130,129,128,131,124,126,129,
128,131,129,127,126,127,129,130,129,129,127,126,127,128,130,129,127,125,127,129,129,130,127,127,127,126,129,128,129,129,124,128,128,129,130,127,127,127,128,128,132,124,128,131,121,133,129,125,133,126,126,132,126,126,135,122,126,131,126,131,132,121,130,129,125,132,130,124,128,128,126,132,129,125,130,126,126,136,125,126,129,126,128,130,130,126,130,124,130,129,126,129,127,128,127,131,126,130,128,126,
129,126,127,129,129,128,128,125,126,130,128,130,128,126,127,128,128,130,128,125,128,128,129,130,128,127,127,127,129,128,128,129,128,126,129,126,130,129,127,126,127,128,131,128,127,128,126,129,132,125,130,127,123,134,127,125,132,126,127,130,125,131,129,125,131,127,125,131,129,126,132,125,127,132,125,129,130,124,130,128,127,131,127,127,128,128,129,130,126,128,128,128,128,129,128,128,128,127,128,127,
129,128,129,128,129,128,127,128,129,127,127,128,128,129,128,128,128,127,127,129,128,129,127,127,129,128,129,128,128,127,128,127,128,129,127,128,127,128,128,128,130,129,127,128,129,127,129,128,126,130,127,127,131,126,128,130,127,128,130,125,129,129,126,130,127,128,127,130,128,128,128,125,130,128,128,130,126,125,131,127,129,130,125,129,128,127,130,130,127,128,128,126,129,129,127,129,127,127,129,128,
127,129,128,126,128,127,129,129,127,128,129,126,129,129,128,128,127,127,127,129,128,129,128,128,128,128,128,129,128,128,127,127,128,128,129,128,128,127,128,128,128,128,128,127,128,128,128,130,128,128,129,127,127,129,128,128,128,127,128,128,127,129,127,128,129,127,129,129,128,129,129,126,128,128,127,129,127,128,129,127,128,128,127,129,128,127,128,129,127,129,128,128,129,128,128,129,129,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,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
};
const uint8_t BO[1474] PROGMEM =
{
128,130,130,129,129,131,159,163,129,129,131,121,127,178,210,178,177,189,165,92,171,206,139,184,141,131,137,104,132,95,140,151,105,143,120,162,106,22,101,54,3,27,10,18,23,54,63,20,28,38,16,29,28,43,112,103,111,185,212,180,135,180,201,160,170,168,186,238,237,235,239,234,236,234,236,237,236,225,196,164,169,178,167,169,177,207,238,233,235,219,177,150,124,97,97,90,
69,66,88,119,104,70,70,75,75,52,59,91,79,91,114,115,118,97,92,95,71,58,45,34,33,38,40,40,56,71,61,51,49,32,33,47,62,89,108,117,134,156,172,169,156,146,142,149,153,148,147,159,188,209,213,212,221,227,224,225,224,223,223,222,222,222,221,221,221,222,224,228,227,206,168,140,131,132,124,101,90,84,70,60,51,35,30,38,47,57,55,39,35,39,36,40,44,41,37,39,
38,40,44,45,54,68,81,94,100,102,109,125,147,157,154,159,166,172,180,187,192,197,200,201,195,184,173,162,149,144,144,148,157,165,166,167,171,174,179,179,173,164,160,168,181,195,196,192,187,172,162,157,148,141,137,134,135,134,130,128,122,121,122,116,107,91,79,76,68,61,58,56,61,65,62,56,51,48,45,43,42,41,49,65,80,93,109,123,133,138,140,144,148,150,162,175,182,192,205,213,
215,214,206,191,177,166,156,152,151,150,157,164,166,167,170,167,158,149,148,147,140,134,132,128,125,122,118,112,105,102,98,97,103,108,113,117,119,121,124,128,136,137,130,124,118,111,103,97,98,104,109,113,118,122,120,114,105,101,98,87,79,80,84,93,103,114,127,136,144,153,161,160,156,151,144,136,133,137,143,148,148,147,147,143,136,131,129,128,131,141,152,165,172,177,186,186,178,167,157,149,
140,133,129,127,127,126,124,127,128,125,122,118,112,110,110,111,111,114,119,123,124,123,118,106,96,94,92,90,93,97,98,103,105,106,108,105,103,105,104,102,107,112,116,123,131,144,156,159,159,157,156,156,155,154,151,148,145,142,141,138,136,134,134,134,134,134,137,137,136,137,139,143,146,148,147,148,149,148,146,143,136,130,126,123,122,123,123,124,128,132,132,129,122,115,110,109,112,115,118,120,
121,121,119,114,107,102,99,95,92,91,90,91,94,98,104,108,112,114,117,123,130,138,143,146,148,148,147,146,147,148,148,149,151,154,157,158,158,158,157,155,149,142,135,127,122,120,119,121,123,125,129,131,136,138,134,130,125,118,113,110,107,106,109,114,119,126,130,130,130,131,130,131,133,134,134,135,134,133,130,123,119,115,112,111,111,112,112,113,115,115,114,115,115,114,114,115,118,121,126,129,
130,132,134,134,133,130,127,127,128,130,133,136,139,143,146,151,153,152,149,145,142,139,135,131,128,126,128,128,129,133,136,139,137,135,133,129,123,115,109,105,105,107,111,117,124,130,136,140,141,140,138,133,129,126,122,121,120,120,122,122,119,117,114,112,112,112,112,113,114,117,120,122,122,121,121,122,121,120,123,126,129,131,134,136,137,137,136,134,133,132,130,129,128,129,131,133,135,139,142,143,
145,145,144,144,143,140,137,134,133,131,131,130,127,124,121,119,118,116,117,120,124,127,130,131,132,133,132,130,128,126,123,120,117,115,113,112,112,112,112,113,113,115,115,112,109,107,106,106,107,109,113,118,124,131,136,139,141,141,141,141,140,139,139,141,141,143,145,147,148,147,145,144,141,140,139,138,137,136,134,133,132,131,130,129,128,127,125,123,121,118,116,113,112,111,110,111,114,118,121,125,
126,128,129,128,126,125,123,122,120,118,117,117,118,121,123,125,126,128,128,125,122,119,116,114,112,111,112,115,118,123,128,133,137,140,142,142,142,142,141,141,140,140,139,138,139,141,143,145,146,147,148,148,146,142,138,133,127,122,118,115,113,113,115,117,118,120,121,121,119,116,111,108,106,105,106,108,111,117,122,127,132,134,136,135,135,133,130,128,125,122,121,120,121,123,125,128,130,131,132,132,
131,130,128,125,123,122,122,123,125,129,131,132,133,133,132,130,129,128,128,130,132,135,137,140,143,144,145,145,144,142,140,138,135,132,129,126,124,121,118,116,115,116,117,118,119,119,120,120,120,118,116,114,112,112,113,115,118,122,125,130,134,137,139,138,137,134,128,124,121,117,116,116,117,120,124,127,130,133,134,134,133,131,129,127,126,126,126,127,128,129,130,130,131,131,132,132,133,134,135,136,
136,136,137,138,138,138,138,137,136,135,133,131,130,128,127,126,125,124,123,122,120,118,116,114,112,111,111,111,112,115,117,118,120,122,123,124,126,127,129,129,129,130,130,129,129,128,127,126,125,124,125,126,127,128,129,129,130,130,130,131,131,131,131,131,131,131,131,132,133,133,133,134,133,133,133,133,134,135,135,136,136,136,137,136,134,133,131,130,128,126,124,122,121,121,120,119,119,118,118,118,
118,116,115,114,113,114,115,116,117,119,121,123,126,127,129,130,130,130,129,129,129,129,130,130,131,133,134,136,137,137,137,136,135,132,129,126,124,122,122,122,123,126,128,130,132,134,134,134,133,132,130,128,127,126,127,128,130,131,133,135,136,136,136,135,134,131,128,125,122,119,117,116,115,117,118,120,121,123,123,123,123,122,121,120,119,119,120,121,123,124,126,128,130,131,133,133,133,133,133,132,
131,130,129,129,130,131,132,134,135,136,136,135,134,132,129,126,124,123,122,121,121,122,124,126,127,129,130,130,130,129,128,127,126,126,127,128,130,132,134,136,137,138,137,135,132,129,125,122,119,117,116,116,117,119,120,122,124,126,127,127,126,125,124,123,122,122,122,123,125,126,129,130,132,134,134,134,134,133,132,131,130,130,129,129,129,130,130,131,131,132,132,132,131,130,128,127,125,124,123,123,
122,123,123,124,125,126,128,129,130,131,131,131,131,131,131,131,130,130,131,131,132,131,131,130,128,127,125,123,122,120,119,119,119,119,120,120,120,121,121,122,122,122,122,123,123,125,126,128,130,132,134,135,136,136,136,135,135,134,133,132,131,132,132,132,133,133,134,133,132,131,130,129,128,127,126,126,125,125,124,124,124,124,124,124,124,125,126,127,128,128,128,129,129,129,129,129,128,128,127,126,
126,125,125,124,124,124,125,125,125,125,125,124,124,123,122,122,122,122,122,123,124,125,126,127,128,130,131,132,133,134,134,135,135,135,135,135,135,135,134,134,135,135,134,133,132,131,129,128,126,125,124,123,123,123,123,124,125,125,126,126,127,127,127,127,127,126,126,125,125,126,126,127,128,129,129,129,129,128
};
ISR(TIMER1_COMPA_vect) {
//------------------- Ringbuffer handler -------------------------
if (RingCount) { //If entry in FIFO..
OCR2A = Ringbuffer[(RingRead++)]; //Output LSB of 16-bit DAC
RingCount--;
}
//-----------------------------------------------------------------
}
void setup() {
OSCCAL=0xFF;
//Drumtrigger inputs
pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
pinMode(5,INPUT_PULLUP);
pinMode(6,INPUT_PULLUP);
pinMode(7,INPUT_PULLUP);
pinMode(8,INPUT_PULLUP);
pinMode(9,INPUT_PULLUP);
pinMode(10,INPUT_PULLUP);
//8-bit PWM DAC pin
pinMode(11,OUTPUT);
// Set up Timer 1 to send a sample every interrupt.
cli();
// Set CTC mode
// Have to set OCR1A *after*, otherwise it gets reset to 0!
TCCR1B = (TCCR1B & ~_BV(WGM13)) | _BV(WGM12);
TCCR1A = TCCR1A & ~(_BV(WGM11) | _BV(WGM10));
// No prescaler
TCCR1B = (TCCR1B & ~(_BV(CS12) | _BV(CS11))) | _BV(CS10);
// Set the compare register (OCR1A).
// OCR1A is a 16-bit register, so we have to do this with
// interrupts disabled to be safe.
//OCR1A = F_CPU / SAMPLE_RATE;
// Enable interrupt when TCNT1 == OCR1A
TIMSK1 |= _BV(OCIE1A);
sei();
OCR1A = 400; //40KHz Samplefreq
// Set up Timer 2 to do pulse width modulation on D11
// Use internal clock (datasheet p.160)
ASSR &= ~(_BV(EXCLK) | _BV(AS2));
// Set fast PWM mode (p.157)
TCCR2A |= _BV(WGM21) | _BV(WGM20);
TCCR2B &= ~_BV(WGM22);
// Do non-inverting PWM on pin OC2A (p.155)
// On the Arduino this is pin 11.
TCCR2A = (TCCR2A | _BV(COM2A1)) & ~_BV(COM2A0);
TCCR2A &= ~(_BV(COM2B1) | _BV(COM2B0));
// No prescaler (p.158)
TCCR2B = (TCCR2B & ~(_BV(CS12) | _BV(CS11))) | _BV(CS10);
// Set initial pulse width to the first sample.
OCR2A = 128;
//set timer0 interrupt at 61Hz
TCCR0A = 0;// set entire TCCR0A register to 0
TCCR0B = 0;// same for TCCR0B
TCNT0 = 0;//initialize counter value to 0
// set compare match register for 62hz increments
OCR0A = 255;// = 61Hz
// turn on CTC mode
TCCR0A |= (1 << WGM01);
// Set CS01 and CS00 bits for prescaler 1024
TCCR0B |= (1 << CS02) | (0 << CS01) | (1 << CS00); //1024 prescaler
TIMSK0=0;
// set up the ADC
SFREQ=analogRead(0);
ADCSRA &= ~PS_128; // remove bits set by Arduino library
// Choose prescaler PS_128.
ADCSRA |= PS_128;
ADMUX = 64;
sbi(ADCSRA, ADSC);
}
void loop() {
uint8_t phaccAG,phaccCA,phaccMA,phaccWH,phaccTI,phaccCH,phaccQU,phaccBO;
uint8_t pitchAG=32;
uint8_t pitchCA=64;
uint8_t pitchMA=64;
uint8_t pitchWH=32;
uint8_t pitchTI=64;
uint8_t pitchCH=16;
uint8_t pitchQU=16;
uint8_t pitchBO=64;
uint16_t samplecntAG,samplecntCA,samplecntMA,samplecntWH,samplecntTI,samplecntCH,samplecntQU,samplecntBO;
uint16_t samplepntAG,samplepntCA,samplepntMA,samplepntWH,samplepntTI,samplepntCH,samplepntQU,samplepntBO;
int16_t total;
uint8_t oldPORTB;
uint8_t oldPORTD;
uint8_t divider;
uint8_t MUX=0;
while(1) {
//------ Add current sample word to ringbuffer FIFO --------------------
if (RingCount<255) { //if space in ringbuffer
total=0;
if (samplecntAG) {
phaccAG+=pitchAG;
if (phaccAG & 128) {
phaccAG &= 127;
total+=(pgm_read_byte_near(AG + samplepntAG)-128);
samplepntAG++;
samplecntAG--;
}
}
if (samplecntBO) {
phaccBO+=pitchBO;
if (phaccBO & 128) {
phaccBO &= 127;
total+=(pgm_read_byte_near(BO + samplepntBO)-128);
samplepntBO++;
samplecntBO--;
}
}
if (samplecntMA) {
phaccMA+=pitchMA;
if (phaccMA & 128) {
phaccMA &= 127;
total+=(pgm_read_byte_near(MA + samplepntMA)-128);
samplepntMA++;
samplecntMA--;
}
}
if (samplecntQU) {
phaccQU+=pitchQU;
if (phaccQU & 128) {
phaccQU &= 127;
total+=(pgm_read_byte_near(QU + samplepntQU)-128);
samplepntQU++;
samplecntQU--;
}
}
if (samplecntCA) {
phaccCA+=pitchCA;
if (phaccCA & 128) {
phaccCA &= 127;
total+=(pgm_read_byte_near(CA + samplepntCA)-128);
samplepntCA++;
samplecntCA--;
}
}
if (samplecntTI) {
phaccTI+=pitchTI;
if (phaccTI & 128) {
phaccTI &= 127;
total+=(pgm_read_byte_near(TI + samplepntTI)-128);
samplepntTI++;
samplecntTI--;
}
}
if (samplecntWH) {
phaccWH+=pitchWH;
if (phaccWH & 128) {
phaccWH &= 127;
total+=(pgm_read_byte_near(WH + samplepntWH)-128);
samplepntWH++;
samplecntWH--;
}
}
if (samplecntCH) {
phaccCH+=pitchCH;
if (phaccCH & 128) {
phaccCH &= 127;
total+=(pgm_read_byte_near(CH + samplepntCH)-128);
samplepntCH++;
samplecntCH--;
}
}
total>>=1;
if (!(PINB&4)) total>>=1;
total+=128;
if (total>255) total=255;
cli();
Ringbuffer[RingWrite]=total;
RingWrite++;
RingCount++;
sei();
}
//----------------------------------------------------------------------------
//----------------- Handle Triggers ------------------------------
if (PIND&4) {
samplepntBO=0;
samplecntBO=1474;
}
if (PIND&8) {
samplepntAG=0;
samplecntAG=1720;
}
if (PIND&16) {
samplepntTI=0;
samplecntTI=3680;
}
if (PIND&32) {
samplepntQU=0;
samplecntQU=6502;
}
if (PIND&64) {
samplepntMA=0;
samplecntMA=394;
}
if (PIND&128) {
samplepntCH=0;
samplecntCH=5596;
}
if (PINB&1) {
samplepntCA=0;
samplecntCA=2174;
}
if (PINB&2) {
samplepntWH=0;
samplecntWH=2670;
}
//-----------------------------------------------------------------
//--------------- ADC block -------------------------------------
if (!(divider++)) {
if (!(ADCSRA & 64)) {
uint16_t pitch=((ADCL+(ADCH<<8))>>3)+1;
if (MUX==0) pitchAG=pitch;
if (MUX==1) pitchTI=pitch;
if (MUX==2) pitchQU=pitch;
if (MUX==3) pitchMA=pitch;
if (MUX==4) pitchCH=pitch;
if (MUX==5) pitchWH=pitch;
MUX++;
if (MUX==6) MUX=0;
ADMUX = 64 | MUX; //Select MUX
sbi(ADCSRA, ADSC); //start next conversation
}
}
//---------------------------------------------------------------
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment