SHARE
TWEET

Untitled

a guest Sep 21st, 2019 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static const uint8_t sin_table[] = {
  2.     0,   1,   3,   4,   6,   7,   9,  10,  12,  14,  15,  17,  18,
  3.         20,  21,  23,  25,  26,  28,  29,  31,  32,  34,  36,  37,  39,
  4.         40,  42,  43,  45,  46,  48,  49,  51,  53,  54,  56,  57,  59,
  5.         60,  62,  63,  65,  66,  68,  69,  71,  72,  74,  75,  77,  78,
  6.         80,  81,  83,  84,  86,  87,  89,  90,  92,  93,  95,  96,  97,
  7.         99, 100, 102, 103, 105, 106, 108, 109, 110, 112, 113, 115, 116,
  8.        117, 119, 120, 122, 123, 124, 126, 127, 128, 130, 131, 132, 134,
  9.        135, 136, 138, 139, 140, 142, 143, 144, 146, 147, 148, 149, 151,
  10.        152, 153, 155, 156, 157, 158, 159, 161, 162, 163, 164, 166, 167,
  11.        168, 169, 170, 171, 173, 174, 175, 176, 177, 178, 179, 181, 182,
  12.        183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
  13.        196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208,
  14.        209, 210, 211, 211, 212, 213, 214, 215, 216, 217, 217, 218, 219,
  15.        220, 221, 221, 222, 223, 224, 225, 225, 226, 227, 227, 228, 229,
  16.        230, 230, 231, 232, 232, 233, 234, 234, 235, 235, 236, 237, 237,
  17.        238, 238, 239, 239, 240, 241, 241, 242, 242, 243, 243, 244, 244,
  18.        244, 245, 245, 246, 246, 247, 247, 247, 248, 248, 249, 249, 249,
  19.        250, 250, 250, 251, 251, 251, 251, 252, 252, 252, 252, 253, 253,
  20.        253, 253, 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255,
  21.        255, 255, 255, 255, 255, 255, 255, 255, 255, 255}; // last should be 256
  22.  
  23. int16_t sin180(uint16_t in) {
  24.     return in < 256 ? sin_table[in] : sin_table[512 - in];
  25. }
  26.  
  27. int16_t isin(uint16_t in) {
  28.     return in < 512 ? sin180(in) : -sin180(1024 - in);
  29. }
  30.  
  31. uint8_t psin(uint16_t in) {
  32.     return (isin(in) + 256) / 2;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top