/* 電子ボリュームコントローラ 更新記録 DATT10.C 2006.10.6 first editing DATT11.C 2006.10.18 DATT12.C 2006.10.22 by h_fujiwara_1995 */ #include<3048f.h> /* IO PORT and AD and DA PORT H8/3048 */ #define adcsr (volatile unsigned char *)0xffffe8 #define addrah (volatile unsigned char *)0xffffe0 #define addral (volatile unsigned char *)0xffffe1 #define dadr0 (volatile unsigned char *)0xffffdc #define dadr1 (volatile unsigned char *)0xffffdd #define dacr (volatile unsigned char *)0xffffde #define dastcr (volatile unsigned char *)0xffff5c #define p1ddr (volatile unsigned char *)0xffffc0 #define p1dr (volatile unsigned char *)0xffffc2 #define p2ddr (volatile unsigned char *)0xffffc1 #define p2dr (volatile unsigned char *)0xffffc3 #define p3ddr (volatile unsigned char *)0xffffc4 #define p3dr (volatile unsigned char *)0xffffc6 #define p4ddr (volatile unsigned char *)0xffffc5 #define p4dr (volatile unsigned char *)0xffffc7 #define p5ddr (volatile unsigned char *)0xffffc8 #define p5pcr (volatile unsigned char *)0xffffdb #define p5dr (volatile unsigned char *)0xffffca #define p6ddr (volatile unsigned char *)0xffffc9 #define p6dr (volatile unsigned char *)0xffffcb #define p7dr (volatile unsigned char *)0xffffce #define p8ddr (volatile unsigned char *)0xffffcd #define p8dr (volatile unsigned char *)0xffffcf #define p9ddr (volatile unsigned char *)0xffffd0 #define p9dr (volatile unsigned char *)0xffffd2 #define paddr (volatile unsigned char *)0xffffd1 #define padr (volatile unsigned char *)0xffffd3 #define pbddr (volatile unsigned char *)0xffffd4 #define pbdr (volatile unsigned char *)0xffffd6 /* 8×8のアスキーフォント 英数字のみ */ /* 間違い部分 '-' をだす場合は ','を選択 '.' をだす場合は '-'を選択 '/' をだす場合は '.'を選択 '/' を選択すると '0' になる。   ',' は出ない。 */ char font[768]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xbf,0x00,0x00,0x00, 0x00,0x0b,0x07,0x00,0x0b,0x07,0x00,0x00,0x20,0xe4,0x3c,0x27,0xe4,0x3c,0x27,0x04, 0x00,0x00,0x24,0x4a,0xff,0x4a,0x34,0x00,0x86,0x49,0x29,0x16,0x68,0x94,0x92,0x61, 0x00,0x36,0x49,0x49,0x56,0x20,0x58,0x00,0x00,0x04,0x07,0x03,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x81,0x81,0x42,0x3c,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x22,0x14,0x7f,0x14,0x22,0x00,0x00,0x08,0x08,0x08,0x7f,0x08,0x08,0x08, 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00, 0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00,0x3e,0x41,0x41,0x41,0x41,0x3e,0x00, 0x00,0x3e,0x41,0x41,0x41,0x41,0x3e,0x00,0x00,0x00,0x00,0x42,0x7f,0x40,0x00,0x00, 0x00,0x42,0x61,0x51,0x49,0x49,0x46,0x00,0x00,0x22,0x49,0x49,0x49,0x49,0x36,0x00, 0x00,0x30,0x28,0x24,0x22,0x7f,0x20,0x00,0x00,0x4f,0x49,0x49,0x49,0x49,0x31,0x00, 0x00,0x3e,0x49,0x49,0x49,0x49,0x32,0x00,0x00,0x01,0x01,0x71,0x09,0x05,0x03,0x00, 0x00,0x36,0x49,0x49,0x49,0x49,0x36,0x00,0x00,0x26,0x49,0x49,0x49,0x49,0x3e,0x00, 0x00,0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0xb6,0x76,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x08,0x14,0x22,0x41,0x00,0x24,0x24,0x24,0x24,0x24,0x24,0x24, 0x41,0x22,0x14,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x01,0xb1,0x09,0x06,0x00, 0x00,0x3c,0x42,0xa9,0xa5,0xbd,0xb2,0x3c,0x00,0x7c,0x12,0x11,0x11,0x12,0x7c,0x00, 0x00,0x7f,0x49,0x49,0x49,0x49,0x36,0x00,0x00,0x1c,0x22,0x41,0x41,0x41,0x22,0x00, 0x00,0x41,0x7f,0x41,0x41,0x22,0x1c,0x00,0x00,0x7f,0x49,0x49,0x49,0x49,0x41,0x00, 0x00,0x7f,0x09,0x09,0x09,0x09,0x01,0x00,0x00,0x1c,0x22,0x41,0x41,0x29,0x7a,0x08, 0x00,0x7f,0x08,0x08,0x08,0x08,0x7f,0x00,0x00,0x00,0x00,0x41,0x7f,0x41,0x00,0x00, 0x00,0x30,0x40,0x40,0x41,0x3f,0x01,0x00,0x00,0x7f,0x10,0x08,0x14,0x22,0x41,0x00, 0x00,0x7f,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x7f,0x02,0x04,0x08,0x04,0x02,0x7f, 0x00,0x7f,0x02,0x04,0x08,0x10,0x7f,0x00,0x00,0x1c,0x22,0x41,0x41,0x22,0x1c,0x00, 0x00,0x7f,0x09,0x09,0x09,0x09,0x06,0x00,0x00,0x1c,0x22,0x41,0x51,0x22,0x5c,0x00, 0x00,0x7f,0x09,0x09,0x19,0x29,0x46,0x00,0x00,0x26,0x49,0x49,0x49,0x49,0x32,0x00, 0x00,0x01,0x01,0x01,0x7f,0x01,0x01,0x01,0x00,0x3f,0x40,0x40,0x40,0x40,0x3f,0x00, 0x00,0x03,0x0c,0x30,0x40,0x30,0x0c,0x03,0x00,0x1f,0x60,0x18,0x06,0x18,0x60,0x1f, 0x00,0x41,0x22,0x14,0x08,0x14,0x22,0x41,0x00,0x01,0x02,0x04,0x78,0x04,0x02,0x01, 0x00,0x41,0x61,0x51,0x49,0x45,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x81,0x81, 0x00,0x29,0x2a,0x2c,0xf8,0x2c,0x2a,0x29,0x81,0x81,0xff,0x00,0x00,0x00,0x00,0x00, 0x00,0x08,0x14,0x22,0x41,0x22,0x14,0x08,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40, 0x00,0x00,0x00,0x00,0x00,0x0e,0x0d,0x00,0x00,0x00,0x20,0x54,0x54,0x54,0x78,0x00, 0x00,0x00,0x7f,0x48,0x48,0x48,0x30,0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x28,0x00, 0x00,0x00,0x30,0x48,0x48,0x48,0x7f,0x00,0x00,0x00,0x38,0x54,0x54,0x54,0x58,0x00, 0x00,0x00,0x08,0x7e,0x09,0x09,0x02,0x00,0x00,0x00,0x98,0xa4,0xa4,0xa4,0x78,0x00, 0x00,0x00,0x7f,0x04,0x04,0x04,0x78,0x00,0x00,0x00,0x00,0x44,0x7d,0x40,0x00,0x00, 0x00,0x40,0x80,0x84,0x7d,0x00,0x00,0x00,0x00,0x00,0x7f,0x10,0x28,0x44,0x00,0x00, 0x00,0x00,0x00,0x01,0x7f,0x00,0x00,0x00,0x00,0x00,0x7c,0x04,0x7c,0x04,0x78,0x00, 0x00,0x00,0x7c,0x04,0x04,0x04,0x78,0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x38,0x00, 0x00,0x00,0xfc,0x24,0x24,0x24,0x18,0x00,0x00,0x00,0x18,0x24,0x24,0x24,0xfc,0x00, 0x00,0x00,0x7c,0x08,0x04,0x04,0x04,0x00,0x00,0x00,0x48,0x54,0x54,0x54,0x24,0x00, 0x00,0x00,0x04,0x3e,0x44,0x44,0x00,0x00,0x00,0x00,0x3c,0x40,0x40,0x40,0x7c,0x00, 0x00,0x00,0x0c,0x30,0x40,0x30,0x0c,0x00,0x00,0x00,0x1c,0x60,0x18,0x60,0x1c,0x00, 0x00,0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00,0x00,0x9c,0xa0,0xa0,0xa0,0x7c,0x00, 0x00,0x00,0x44,0x64,0x54,0x4c,0x44,0x00,0x00,0x00,0x00,0x00,0x08,0x76,0x81,0x81, 0x00,0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x81,0x81,0x76,0x08,0x00,0x00,0x00,0x00, 0x00,0x08,0x04,0x04,0x08,0x10,0x10,0x08,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00}; /* AD変換値(0-1023)を内部データ(200-1000)に変換するデーブル */ unsigned int Table1[1024]={ 200, 200, 200, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 470, 471, 471, 472, 472, 473, 473, 474, 474, 475, 475, 476, 476, 477, 478, 478, 479, 479, 480, 480, 481, 481, 482, 482, 483, 483, 484, 485, 485, 486, 486, 487, 487, 488, 488, 489, 489, 490, 490, 491, 492, 492, 493, 493, 494, 494, 495, 495, 496, 496, 497, 497, 498, 498, 499, 500, 500, 501, 501, 502, 502, 503, 503, 504, 504, 505, 505, 506, 507, 507, 508, 508, 509, 509, 510, 510, 511, 511, 512, 512, 513, 514, 514, 515, 515, 516, 516, 517, 517, 518, 518, 519, 519, 520, 521, 521, 522, 522, 523, 523, 524, 524, 525, 525, 526, 526, 527, 527, 528, 529, 529, 530, 530, 531, 531, 532, 532, 533, 533, 534, 534, 535, 536, 536, 537, 537, 538, 538, 539, 539, 540, 540, 541, 541, 542, 543, 543, 544, 544, 545, 545, 546, 546, 547, 547, 548, 548, 549, 550, 550, 551, 551, 552, 552, 553, 553, 554, 554, 555, 555, 556, 556, 557, 558, 558, 559, 559, 560, 560, 561, 561, 562, 562, 563, 563, 564, 565, 565, 566, 566, 567, 567, 568, 568, 569, 569, 570, 570, 571, 572, 572, 573, 573, 574, 574, 575, 575, 576, 576, 577, 577, 578, 579, 579, 580, 580, 581, 581, 582, 582, 583, 583, 584, 584, 585, 585, 586, 587, 587, 588, 588, 589, 589, 590, 590, 591, 591, 592, 592, 593, 594, 594, 595, 595, 596, 596, 597, 597, 598, 598, 599, 599, 600, 601, 601, 602, 602, 603, 603, 604, 604, 605, 605, 606, 606, 607, 608, 608, 609, 609, 610, 610, 611, 611, 612, 612, 613, 613, 614, 614, 615, 616, 616, 617, 617, 618, 618, 619, 619, 620, 620, 621, 621, 622, 623, 623, 624, 624, 625, 625, 626, 626, 627, 627, 628, 628, 629, 630, 630, 631, 631, 632, 632, 633, 633, 634, 634, 635, 635, 636, 637, 637, 638, 638, 639, 639, 640, 640, 641, 641, 642, 642, 643, 643, 644, 645, 645, 646, 646, 647, 647, 648, 648, 649, 649, 650, 650, 651, 652, 652, 653, 653, 654, 654, 655, 655, 656, 656, 657, 657, 658, 659, 659, 660, 660, 661, 661, 662, 662, 663, 663, 664, 664, 665, 665, 666, 667, 667, 668, 668, 669, 669, 670, 670, 671, 671, 672, 672, 673, 674, 674, 675, 675, 676, 676, 677, 677, 678, 678, 679, 679, 680, 681, 681, 682, 682, 683, 683, 684, 684, 685, 685, 686, 686, 687, 688, 688, 689, 689, 690, 690, 691, 691, 692, 692, 693, 693, 694, 694, 695, 696, 696, 697, 697, 698, 698, 699, 699, 700, 700, 701, 701, 702, 703, 703, 704, 704, 705, 705, 706, 706, 707, 707, 708, 708, 709, 710, 710, 711, 711, 712, 712, 713, 713, 714, 714, 715, 715, 716, 717, 717, 718, 718, 719, 719, 720, 720, 721, 721, 722, 722, 723, 723, 724, 725, 725, 726, 726, 727, 727, 728, 728, 729, 729, 730, 730, 731, 732, 732, 733, 733, 734, 734, 735, 735, 736, 736, 737, 737, 738, 739, 739, 740, 740, 741, 741, 742, 742, 743, 743, 744, 744, 745, 746, 746, 747, 747, 748, 748, 749, 749, 750, 750, 751, 751, 752, 752, 753, 754, 754, 755, 755, 756, 756, 757, 757, 758, 758, 759, 759, 760, 761, 761, 762, 762, 763, 763, 764, 764, 765, 765, 766, 766, 767, 768, 768, 769, 769, 770, 770, 771, 771, 772, 772, 773, 773, 774, 775, 775, 776, 776, 777, 777, 778, 778, 779, 779, 780, 780, 781, 781, 782, 783, 783, 784, 784, 785, 785, 786, 786, 787, 787, 788, 788, 789, 790, 790, 791, 791, 792, 792, 793, 793, 794, 794, 795, 795, 796, 797, 797, 798, 798, 799, 799, 800, 800, 801, 801, 802, 802, 803, 804, 804, 805, 805, 806, 806, 807, 807, 808, 808, 809, 809, 810, 810, 811, 812, 812, 813, 813, 814, 814, 815, 815, 816, 816, 817, 817, 818, 819, 819, 820, 820, 821, 821, 822, 822, 823, 823, 824, 824, 825, 826, 826, 827, 827, 828, 828, 829, 829, 830, 830, 831, 831, 832, 832, 833, 834, 834, 835, 835, 836, 836, 837, 837, 838, 838, 839, 839, 840, 841, 841, 842, 842, 843, 843, 844, 844, 845, 845, 846, 846, 847, 848, 848, 849, 849, 850, 850, 851, 851, 852, 852, 853, 853, 854, 855, 855, 856, 856, 857, 857, 858, 858, 859, 859, 860, 860, 861, 861, 862, 863, 863, 864, 864, 865, 865, 866, 866, 867, 867, 868, 868, 869, 870, 870, 871, 871, 872, 872, 873, 873, 874, 874, 875, 875, 876, 877, 877, 878, 878, 879, 879, 880, 880, 881, 881, 882, 882, 883, 884, 884, 885, 885, 886, 886, 887, 887, 888, 888, 889, 889, 890, 890, 891, 892, 892, 893, 893, 894, 894, 895, 895, 896, 896, 897, 897, 898, 899, 899, 900, 900, 901, 901, 902, 902, 903, 903, 904, 904, 905, 906, 906, 907, 907, 908, 908, 909, 909, 910, 910, 911, 911, 912, 913, 913, 914, 914, 915, 915, 916, 916, 917, 917, 918, 918, 919, 919, 920, 921, 921, 922, 922, 923, 923, 924, 924, 925, 925, 926, 926, 927, 928, 928, 929, 929, 930, 930, 931, 931, 932, 932, 933, 933, 934, 935, 935, 936, 936, 937, 937, 938, 938, 939, 939, 940, 940, 941, 942, 942, 943, 943, 944, 944, 945, 945, 946, 946, 947, 947, 948, 948, 949, 950, 950, 951, 951, 952, 952, 953, 953, 954, 954, 955, 955, 956, 957, 957, 958, 958, 959, 959, 960, 960, 961, 961, 962, 962, 963, 964, 964, 965, 965, 966, 966, 967, 967, 968, 968, 969, 969, 970, 971, 971, 972, 972, 973, 973, 974, 974, 975, 975, 976, 976, 977, 977, 978, 979, 979, 980, 980, 981, 981, 982, 982, 983, 983, 984, 984, 985, 986, 986, 987, 987, 988, 988, 989, 989, 990, 990, 991, 991, 992, 993, 993, 994, 994, 995, 995, 996, 996, 997, 997, 998, 998, 999, 999, 1000, 1000, 1000, 1000, 1000, 1000}; /* 内部データ(0-1000)をR-2Rコード(0-65535)に変換するテーブル */ unsigned int Table2[1001]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 36, 36, 37, 37, 38, 38, 39, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 49, 49, 50, 50, 51, 51, 52, 53, 53, 54, 55, 55, 56, 56, 57, 58, 58, 59, 60, 60, 61, 62, 63, 63, 64, 65, 66, 66, 67, 68, 69, 69, 70, 71, 72, 73, 74, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 83, 84, 85, 86, 87, 88, 89, 90, 92, 93, 94, 95, 96, 97, 98, 99, 100, 102, 103, 104, 105, 106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 119, 121, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 139, 140, 142, 143, 145, 147, 148, 150, 152, 154, 155, 157, 159, 161, 163, 165, 167, 168, 170, 172, 174, 176, 178, 181, 183, 185, 187, 189, 191, 193, 196, 198, 200, 203, 205, 207, 210, 212, 215, 217, 220, 222, 225, 227, 230, 233, 235, 238, 241, 243, 246, 249, 252, 255, 258, 261, 264, 267, 270, 273, 276, 280, 283, 286, 289, 293, 296, 300, 303, 307, 310, 314, 317, 321, 325, 328, 332, 336, 340, 344, 348, 352, 356, 360, 364, 369, 373, 377, 381, 386, 390, 395, 399, 404, 409, 414, 418, 423, 428, 433, 438, 443, 448, 453, 459, 464, 469, 475, 480, 486, 491, 497, 503, 509, 515, 521, 527, 533, 539, 545, 551, 558, 564, 571, 577, 584, 591, 598, 605, 612, 619, 626, 633, 640, 648, 655, 663, 671, 678, 686, 694, 702, 710, 719, 727, 735, 744, 752, 761, 770, 779, 788, 797, 806, 816, 825, 835, 844, 854, 864, 874, 884, 894, 905, 915, 926, 936, 947, 958, 969, 981, 992, 1003, 1015, 1027, 1039, 1051, 1063, 1075, 1088, 1100, 1113, 1126, 1139, 1152, 1165, 1179, 1193, 1206, 1220, 1234, 1249, 1263, 1278, 1293, 1308, 1323, 1338, 1354, 1369, 1385, 1401, 1417, 1434, 1450, 1467, 1484, 1501, 1519, 1536, 1554, 1572, 1590, 1609, 1627, 1646, 1665, 1685, 1704, 1724, 1744, 1764, 1784, 1805, 1826, 1847, 1868, 1890, 1912, 1934, 1957, 1979, 2002, 2025, 2049, 2072, 2096, 2121, 2145, 2170, 2195, 2221, 2246, 2272, 2299, 2325, 2352, 2379, 2407, 2435, 2463, 2492, 2520, 2550, 2579, 2609, 2639, 2670, 2701, 2732, 2764, 2796, 2828, 2861, 2894, 2927, 2961, 2996, 3030, 3065, 3101, 3137, 3173, 3210, 3247, 3285, 3323, 3361, 3400, 3439, 3479, 3519, 3560, 3601, 3643, 3685, 3728, 3771, 3815, 3859, 3904, 3949, 3995, 4041, 4088, 4135, 4183, 4231, 4280, 4330, 4380, 4431, 4482, 4534, 4586, 4640, 4693, 4748, 4803, 4858, 4915, 4971, 5029, 5087, 5146, 5206, 5266, 5327, 5389, 5451, 5514, 5578, 5643, 5708, 5774, 5841, 5909, 5977, 6046, 6116, 6187, 6259, 6331, 6404, 6479, 6554, 6629, 6706, 6784, 6862, 6942, 7022, 7104, 7186, 7269, 7353, 7438, 7525, 7612, 7700, 7789, 7879, 7970, 8063, 8156, 8250, 8346, 8443, 8540, 8639, 8739, 8841, 8943, 9046, 9151, 9257, 9364, 9473, 9583, 9693, 9806, 9919, 10034, 10150, 10268, 10387, 10507, 10629, 10752, 10876, 11002, 11130, 11258, 11389, 11521, 11654, 11789, 11926, 12064, 12203, 12345, 12488, 12632, 12779, 12926, 13076, 13228, 13381, 13536, 13692, 13851, 14011, 14174, 14338, 14504, 14672, 14842, 15013, 15187, 15363, 15541, 15721, 15903, 16087, 16273, 16462, 16653, 16845, 17040, 17238, 17437, 17639, 17843, 18050, 18259, 18471, 18684, 18901, 19120, 19341, 19565, 19792, 20021, 20253, 20487, 20724, 20964, 21207, 21453, 21701, 21952, 22206, 22464, 22724, 22987, 23253, 23522, 23795, 24070, 24349, 24631, 24916, 25205, 25496, 25792, 26090, 26392, 26698, 27007, 27320, 27636, 27956, 28280, 28608, 28939, 29274, 29613, 29956, 30303, 30653, 31008, 31368, 31731, 32098, 32470, 32846, 33226, 33611, 34000, 34394, 34792, 35195, 35602, 36015, 36432, 36854, 37280, 37712, 38149, 38590, 39037, 39489, 39947, 40409, 40877, 41350, 41829, 42314, 42804, 43299, 43801, 44308, 44821, 45340, 45865, 46396, 46933, 47477, 48026, 48583, 49145, 49714, 50290, 50872, 51461, 52057, 52660, 53270, 53886, 54510, 55142, 55780, 56426, 57079, 57740, 58409, 59085, 59770, 60462, 61162, 61870, 62586, 63311, 64044, 64786, 65535}; /* エンコーダ値(0-557)を内部データ(200-1000)に変換するテーブル */ unsigned int Table3[558]={ 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000}; /* 7 セグメントの表示テーブル */ int seg7[11]={0x7b,0x09,0xe3,0xab,0x99,0xba,0xfa,0x0b,0xfb,0xbb,0x00}; /* バー表示の下に出す目盛りのグラフィックデータ */ unsigned char Bar[122]={ 251, 138, 138, 138, 250, 2, 2, 2, 2, 2, 2, 2, 2, 18, 251, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 234, 170, 171, 170, 186, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 170, 170, 171, 170, 250, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 58,34,35,250,34, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 186, 170, 171, 170, 234, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 250, 170, 171, 170, 234, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10, 10, 235, 26, 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 250, 170, 171, 168, 248}; int ENCp,ENCwait,ENC; /* Encorder parameter */ int VOL,BAL,S1,S2,S3,S4; /* setting value */ int VOLp,BALp,S1p,S2p,S3p,S4p; /* previous value */ int VOLd,BALd,S1d,S2d,S3d,S4d; /* direction 1:increase 0:decrease */ int VOLc,BALc,S1c,S2c,S3c,S4c; /* change flag */ int MUTE1,MUTE2; /* MUTE CONTROL MUTE2 FOR CN5 MUTE1 for CN4 */ int V0,V1,V2,V3,V4,V5,V6,V7; /* VOLUME SETTING DATA*/ int V0i,V1i,V2i,V3i,V4i,V5i,V6i,V7i; /* VOLUME SETTING BINARY DATA*/ int Boff0,Boff1; /* Balance offset */ int GrLCD_FLAG; /* 1:GrLCD ON 0:No */ int BAL_FLAG; /* 1:BALANCE ON */ int ENCORDER_FLAG; /* 1:ENCORDER ON for main volume */ int VR_FLAG; /* 1:VR ON for main volume */ int SPEED_FLAG; /* 1:SPEED CONTROL FLAG */ int S2_FLAG; /* 1:INDIPENDENT CONTROL */ int S3_FLAG; /* 1:INDIPENDENT CONTROL */ int S4_FLAG; /* 1:INDIPENDENT CONTROL */ /* AD PORT CH.7 WF CH.6 M1 CH.5 M2 CH.4 TW CH.3 AUX CH.2 SUB VOLUME CH.1 balance (CN10) CH.0 main volume (CN9) P1-0 to 7 G-LCD DATA  グラフィックLCD用ポート P3-0 G-LCD A0 P3-1 G-LCD CS1 P3-2 G-LCD CS2 P3-3 G-LCD RD P3-4 G-LCD WR CN-5 PA-0 SELECT 0 PA-1 SELECT 1 PA-2 SELECT 2 PA-3 N.C PA-4 MUTE (INACTIVE HIGH) PA-5 CS (When Low output Low) PA-6 STROBE(CLOCK OF 74HC4094) PA-7 DATA CN-4 PA-0 SELECT 0 PA-1 SELECT 1 PA-2 SELECT 2 PA-3 N.C PA-4 MUTE (INACTIVE HIGH) PA-5 CS (When Low output Low) PA-6 STROBE(CLOCK OF 74HC4094) PA-7 DATA P2-0 to 7 DIP-SW INPUT P6-4,5 Rotary Encorder INPUT P5-1 Display content select */ /* HARDWARE PORT INITIALIZE */ PORT_INITIALIZE() { *p1ddr = 0xff; /* G-LCD DATA output */ *p3ddr = 0x1f; /* G-LCD CONTROL */ *p3dr = 0x1f; *p2ddr = 0x00; /* DIP SW INPUT */ *paddr = 0xff; /* CN5 OUTPUT */ *pbddr = 0xff; /* CN4 OUTPUT */ *padr = *pbdr = 0x00; *p9ddr = 0xff; /* CN9 OUTPUT */ *p6ddr = 0x00; /* ENCORDER INPUT */ *p5ddr = 0x00; /* P5 INPUT */ *p5pcr = 0xff; /* P5 PULL UP */ } /* INITIALIZE ADC */ void InitializeADC() { AD.CSR.BIT.SCAN = 0; AD.CSR.BIT.CKS = 0; AD.CSR.BIT.CH = 0; } /* Single DATA Aquisition */ unsigned int get_ad(char ch) { unsigned int n; AD.CSR.BIT.CH = ch; AD.CSR.BIT.ADST = 1; while(AD.CSR.BIT.ADF ==0) ; switch(ch) { case 0 :n = AD.DRA; break; case 1 :n = AD.DRB; break; case 2 :n = AD.DRC; break; case 3 :n = AD.DRD; break; case 4 :n = AD.DRA; break; case 5 :n = AD.DRB; break; case 6 :n = AD.DRC; break; case 7 :n = AD.DRD; break; } AD.CSR.BIT.ADF=0; AD.CSR.BIT.ADST=0; return(n>>6); } int get_ad4(n) int n; /* 4回のAD変換値の平均値を得る */ { int i,j; j=0; for(i=0;i<4;i++) j+=get_ad(n); return((j>>2)&0x3ff); } /* Graphic LCD SG12232 Control routine */ /* Connection P1 PORT to connected to DATA PORT of LCD P3-0 A0 P3-1 CS1 P3-2 CS2 P3-3 RD (Z80 MODE) P3-4 WR (Z80 MODE) */ GrLCD_CLEAR(){ int i,j; for(i=0;i<4;i++){GrLCD_PSET(0,i,0);for(j=0;j<61;j++) GrLCD_DATA(0,0);} for(i=0;i<4;i++){GrLCD_PSET(1,i,0);for(j=0;j<61;j++) GrLCD_DATA(1,0);} } GrLCD_PSET(l,p,c) int l,p,c;{ if(l){ GrLCD_COM_WRITE2((char)(0xb8 + p));GrLCD_COM_WRITE2((char)(c));} else { GrLCD_COM_WRITE1((char)(0xb8 + p));GrLCD_COM_WRITE1((char)(c));}} GrLCD_DATA(l,n) int l,n;{ if(l) GrLCD_DATA_WRITE2((char)n);else GrLCD_DATA_WRITE1((char)n);} GrLCD_DATA_WRITE1(n) unsigned char n;{ while(GrLCD_STATUS1()&0x80){} *p1dr = n; *p3dr = 0xfd; *p3dr = 0xed; /*WR enable */ *p3dr = 0xfd; /*WR disable */ *p3dr = 0xfd; } GrLCD_DATA_WRITE2(n) unsigned char n;{ while(GrLCD_STATUS2()&0x80){} *p1dr = n; *p3dr = 0xfb; *p3dr = 0xeb; /*WR enable */ *p3dr = 0xfb; /*WR disable */ *p3dr = 0xfb; } GrLCD_COM_WRITE1(n) unsigned char n;{ while(GrLCD_STATUS1()&0x80){} *p1dr = n; *p3dr = 0xfc; *p3dr = 0xec; /*WR enable */ *p3dr = 0xfc; /*WR disable */ *p3dr = 0xfc; } GrLCD_COM_WRITE2(n) unsigned char n;{ while(GrLCD_STATUS2()&0x80){} *p1dr = n; *p3dr = 0xfa; *p3dr = 0xea; /*WR enable */ *p3dr = 0xfa; /*WR disable */ *p3dr = 0xfa; } GrLCD_STATUS1(){ char i; *p3dr = 0xfc; *p1ddr = 0x00; *p3dr = 0xf4; i = *p1dr; *p3dr = 0xfc; *p1ddr = 0xff; if(!GrLCD_FLAG) return(0); else return(i); } GrLCD_STATUS2(){ char i; *p3dr = 0xfa; *p1ddr = 0x00; *p3dr = 0xf2; i = *p1dr; *p3dr = 0xfa; *p1ddr = 0xff; if(!GrLCD_FLAG) return(0); else return(i); } GrLCD_ON(){GrLCD_COM_WRITE1(0xaf);GrLCD_COM_WRITE2(0xaf);} GrLCD_OFF(){GrLCD_COM_WRITE1(0xae);GrLCD_COM_WRITE2(0xae);} GrLCD_check() { int i,j; i=0; GrLCD_PSET(0,0,0); for(j=0;j<61;j++) GrLCD_DATA(0,font[i++]); GrLCD_PSET(1,0,0); for(j=0;j<61;j++) GrLCD_DATA(1,font[i++]); GrLCD_PSET(0,1,0); for(j=0;j<61;j++) GrLCD_DATA(0,font[i++]); GrLCD_PSET(1,1,0); for(j=0;j<61;j++) GrLCD_DATA(1,font[i++]); GrLCD_PSET(0,2,0); for(j=0;j<61;j++) GrLCD_DATA(0,font[i++]); GrLCD_PSET(1,2,0); for(j=0;j<61;j++) GrLCD_DATA(1,font[i++]); GrLCD_PSET(0,3,0); for(j=0;j<61;j++) GrLCD_DATA(0,font[i++]); GrLCD_PSET(1,3,0); for(j=0;j<61;j++) GrLCD_DATA(1,font[i++]); } /* 最大2桁の正整数を表示する */ GrLCD_int2(c,p,l,n) int c,p,l,n; { int i; GrLCD_PSET(c,p,l); if(n>=10){ GrLCD_font(c,'0'+n/10);n = n%10; GrLCD_font(c,'0'+n); } else { GrLCD_font(c,' '); GrLCD_font(c,'0'+n); } } /* 最大3桁の正整数を表示する */ GrLCD_int3(c,p,l,n) int c,p,l,n; { int i; GrLCD_PSET(c,p,l); if(n>=100){ GrLCD_font(c,'0'+n/100);n = n%100; GrLCD_font(c,'0'+n/10);n = n%10; GrLCD_font(c,'0'+n); } else if(n>=10){ GrLCD_font(c,' '); GrLCD_font(c,'0'+n/10);n = n%10; GrLCD_font(c,'0'+n); } else { GrLCD_font(c,' '); GrLCD_font(c,' '); GrLCD_font(c,'0'+n); } } /* 最大4桁の正整数を表示する */ GrLCD_int4(c,p,l,n) int c,p,l,n; { int i; GrLCD_PSET(c,p,l); if(n>=1000){ GrLCD_font(c,'0'+n/1000);n = n%1000; GrLCD_font(c,'0'+n/100);n = n%100; GrLCD_font(c,'0'+n/10);n = n%10; GrLCD_font(c,'0'+n); } else { GrLCD_font(c,' '); GrLCD_int3(c,p,l+7,n);} } /* 文字列を表示する */ GrLCD_str(c,p,l,s) int c,p,l;char *s;{ GrLCD_PSET(c,p,l); while(*s){GrLCD_font(c,(*s)&0xff);s++;} } GrLCD_font(c,n) int c,n;{ int i;char *p; p = &font[(n-32)*8]; for(i=0;i<8;i++) GrLCD_DATA(c,*p++); } isqrt(x,y) int x,y;{ long a,b,b2; int i; a = x; b=y; a = a*a+b*b; b = x+y; for(i=0;i<6;i++){b2 = b-b/2+a/(2*b);b = b2;} return((int)b); } WaitLong(){int i,j; for(i=0;i<30000;i++) for(j=0;j<40;j++){}} iabs(n) int n;{if(n<0) return(-n); else return(n);} SOUT16_CN5(ch,dat) int ch,dat; { unsigned char p,p1,p2,p3,p4; int i; p = *padr; p &= 0xf8; p |= (ch & 7); for(i=0;i<16;i++){ if(dat&0x8000) p&=0x7f; else p|=0x80; /* reverse data */ *padr = p; *pbdr = p | 0x10; p&=0xdf; *padr = p; *pbdr = p | 0x10; p|=0x20; *padr = p; *pbdr = p | 0x10; p&=0xdf; *padr = p; *pbdr = p | 0x10; dat = dat << 1; } p1 = p&0xbf; p2 = p|0x40; *padr = p2; *pbdr = p2 | 0x10; *padr = p1; *pbdr = p1 | 0x10; } printhex(n) int n; { if(n&0x8000) GrLCD_str(0,1,0,"1"); else GrLCD_str(0,1,0,"0"); if(n&0x4000) GrLCD_str(0,1,8,"1"); else GrLCD_str(0,1,8,"0"); if(n&0x2000) GrLCD_str(0,1,16,"1"); else GrLCD_str(0,1,16,"0"); if(n&0x1000) GrLCD_str(0,1,24,"1"); else GrLCD_str(0,1,24,"0"); if(n&0x0800) GrLCD_str(0,1,32,"1"); else GrLCD_str(0,1,32,"0"); if(n&0x0400) GrLCD_str(0,1,40,"1"); else GrLCD_str(0,1,40,"0"); if(n&0x0200) GrLCD_str(0,1,48,"1"); else GrLCD_str(0,1,48,"0"); if(n&0x0100) GrLCD_str(0,1,56,"1"); else GrLCD_str(0,1,56,"0"); if(n&0x0080) GrLCD_str(0,2,0,"1"); else GrLCD_str(0,2,0,"0"); if(n&0x0040) GrLCD_str(0,2,8,"1"); else GrLCD_str(0,2,8,"0"); if(n&0x0020) GrLCD_str(0,2,16,"1"); else GrLCD_str(0,2,16,"0"); if(n&0x0010) GrLCD_str(0,2,24,"1"); else GrLCD_str(0,2,24,"0"); if(n&0x0008) GrLCD_str(0,2,32,"1"); else GrLCD_str(0,2,32,"0"); if(n&0x0004) GrLCD_str(0,2,40,"1"); else GrLCD_str(0,2,40,"0"); if(n&0x0002) GrLCD_str(0,2,48,"1"); else GrLCD_str(0,2,48,"0"); if(n&0x0001) GrLCD_str(0,2,56,"1"); else GrLCD_str(0,2,56,"0"); } /* 液晶表示関係 */ DispFormat1() { GrLCD_CLEAR(); GrLCD_str(0,0,0,"S1"); if(S2_FLAG) GrLCD_str(0,1,0,"V2 "); else GrLCD_str(0,1,0,"S2 "); if(S3_FLAG) GrLCD_str(0,2,0,"V3 "); else GrLCD_str(0,2,0,"S3 "); if(S4_FLAG) GrLCD_str(0,3,0,"V4 "); else GrLCD_str(0,3,0,"S4 "); } DispFormat2() { int i; unsigned char *p; GrLCD_CLEAR(); GrLCD_str(1,0,0,"VOL"); GrLCD_PSET(0,3,0); p = Bar; for(i=0;i<61;i++) GrLCD_DATA(0,*p++); GrLCD_PSET(1,3,0); for(i=0;i<61;i++) GrLCD_DATA(1,*p++); } DispFormat3() { int i; unsigned char *p; GrLCD_CLEAR(); GrLCD_PSET(0,3,0); p = Bar; for(i=0;i<61;i++) GrLCD_DATA(0,*p++); GrLCD_PSET(1,3,0); for(i=0;i<61;i++) GrLCD_DATA(1,*p++); } DispDataWithFormat1() { int n; if(VOLc && VR_FLAG){ n=Table1[VOL]; n-=200; DispDataP(1,0,28,n); } if(VOLc && ENCORDER_FLAG){ n=Table3[ENC]; n-=200; DispDataP(1,0,28,n); } if(S1c){ n=(1000-S1)/5; if(n<0) n=0; DispDataS(0,0,16,n); } if(S2c){ if(!S2_FLAG){ n=(1000-S2)/5; if(n<0) n=0; DispDataS(0,1,16,n); } else{ n=Table1[S2]-200; if(n<0) n=0; DispDataP(0,1,24,n); } } if(S3c){ if(!S3_FLAG){ n=(1000-S3)/5; if(n<0) n=0; DispDataS(0,2,16,n); } else{ n=Table1[S3]-200; if(n<0) n=0; DispDataP(0,2,24,n); } } if(S4c){ if(!S4_FLAG){ n=(1000-S4)/5; if(n<0) n=0; DispDataS(0,3,16,n); } else{ n=Table1[S4]-200; if(n<0) n=0; DispDataP(0,3,24,n); } } if(BALc && BAL_FLAG){ if(Boff0){ GrLCD_PSET(1,1,0); GrLCD_font(1,' '); GrLCD_font(1,' '); GrLCD_font(1,'L'); DispDataS2(1,1,24,Boff0); } else if(Boff1){ GrLCD_PSET(1,1,0); GrLCD_font(1,' '); GrLCD_font(1,' '); GrLCD_font(1,'R'); DispDataS2(1,1,24,Boff1); } else GrLCD_str(1,1,0,"NTR "); } } DispDataWithFormat2() { int n; if(VOLc && VR_FLAG){ n=Table1[VOL]; n-=200; DispDataP(1,0,28,n); n=n*3; n/=20; LCDBarDisp(n); } if(VOLc && ENCORDER_FLAG){ n=Table3[ENC]; n-=200; DispDataP(1,0,28,n); n=n*3; n/=20; LCDBarDisp(n); } if(BALc && BAL_FLAG){ if(Boff0){ GrLCD_PSET(1,1,0); GrLCD_font(1,' '); GrLCD_font(1,' '); GrLCD_font(1,'L'); DispDataS2(1,1,24,Boff0); } else if(Boff1){ GrLCD_PSET(1,1,0); GrLCD_font(1,' '); GrLCD_font(1,' '); GrLCD_font(1,'R'); DispDataS2(1,1,24,Boff1); } else GrLCD_str(1,1,0,"NTR "); } } DispDataWithFormat3() { int n; if(VOLc && VR_FLAG){ n=Table1[VOL]; n-=200; n=n*3; n/=20; LCDBarDisp3(n); } if(VOLc && ENCORDER_FLAG){ n=Table3[ENC]; n-=200; n=n*3; n/=20; LCDBarDisp3(n); } } LCDBarDisp(n) int n;{ int i,j; GrLCD_PSET(0,2,0); for(j=0;j<61;j++){if(j=100) n=99; if(n<0) n=0; if(n>=10){ a1=n/10;n = n%10; a1 = seg7[a1]; a2=n; a2 = seg7[a2]; } else { a1 = 10; a2 =seg7[n]; } SOUT_7seg(a1,a2); } /**************** ボリューム調整関連部 *****************/ InitializeParameter() { int p; VOL = VOLp = get_ad4(0); /* main volume */ BAL = BALp = get_ad4(1); /* Balance control */ S1 = S1p = get_ad4(2); /* Level offset of S1*/ S2 = S2p = get_ad4(3); /* Level offset of S2*/ S3 = S3p = get_ad4(4); /* Level offset of S3*/ S4 = S4p = get_ad4(5); /* Level offset of S4*/ VOLd=BALd=S1d=S2d=S3d=S3d=1;/* initial direction */ ENCp=*p6dr&0x10; Boff0=Boff1=0; VR_FLAG = ENCORDER_FLAG = 0; p = *p2dr; if(p&0x01) GrLCD_FLAG = 0; else GrLCD_FLAG=1; if(p&0x02) BAL_FLAG = 0; else BAL_FLAG=1; if(p&0x04) VR_FLAG = 1; else ENCORDER_FLAG=1; if(p&0x10) SPEED_FLAG = 0; else SPEED_FLAG=1; if(p&0x20) S2_FLAG = 0; else S2_FLAG = 1; if(p&0x40) S3_FLAG = 0; else S3_FLAG = 1; if(p&0x81) S4_FLAG = 0; else S4_FLAG = 1; if(ENCORDER_FLAG) VOL=0; ENCwait = 1; ENC=0; } /* AD値を元にアッテネータの設定値(内部データ)を構成する。*/ SetAttenuation() { int i,m; if(BAL_FLAG){ if(BAL>552) Boff0 = ((BAL-552)*10)/23; else if(BAL<472) Boff1 =-((BAL-472)*10)/23; if(Boff0>200) Boff0=200; if(Boff1>200) Boff1=200; } if(VR_FLAG) m=Table1[VOL]; if(ENCORDER_FLAG) m=Table3[ENC]; V0 = m-Boff0;if(V0<0) V0=0; V1 = m-Boff1;if(V1<0) V1=0; i=(1000-S1)/5; if(i<0) i=0; V0 = V0 - i; if(V0<0) V0=0; V1 = V1 - i; if(V1<0) V1=0; if(S2_FLAG){ V2 = (i=Table1[S2])-Boff0; V3 = i-Boff1; if(V2<0) V2=0; if(V3<0) V3=0; }else{ i=(1000-S2)/5; if(i<0) i=0; V2 = m-Boff0-i; if(V2<0) V2=0; V3 = m-Boff1-i; if(V3<0) V3=0; } if(S3_FLAG){ V4 = (i=Table1[S3])-Boff0; V5 = i-Boff1; if(V4<0) V4=0; if(V5<0) V5=0; }else{ i=(1000-S3)/5; if(i<0) i=0; V4 = m-Boff0-i; if(V4<0) V4=0; V5 = m-Boff1-i; if(V5<0) V5=0; } if(S4_FLAG){ V6 = (i=Table1[S4])-Boff0; V7 = i-Boff1; if(V6<0) V6=0; if(V7<0) V7=0; }else{ i=(1000-S4)/5; if(i<0) i=0; V6 = m-Boff0-i; if(V6<0) V6=0; V7 = m-Boff1-i; if(V7<0) V7=0; } } /* ID0〜7までの基板に設定データ(内部管理データ)をバイナリー変換して送信する。 メインVOLのAD値が5以下の場合はすべてMUTE状態とする。 */ Send_ATT_Data() { if(VR_FLAG && VOL<3){ /*MUTE_ON */ *padr = 0x00; } else if(ENCORDER_FLAG && ENC==0){ /*MUTE_ON */ *padr = 0x00; } else *padr = *pbdr = 0x10; SOUT16_CN5(0,V0i=Table2[V0]); SOUT16_CN5(1,V1i=Table2[V1]); SOUT16_CN5(2,V2i=Table2[V2]); SOUT16_CN5(3,V3i=Table2[V3]); SOUT16_CN5(4,V4i=Table2[V4]); SOUT16_CN5(5,V5i=Table2[V5]); SOUT16_CN5(6,V6i=Table2[V6]); SOUT16_CN5(7,V7i=Table2[V7]); } /* ボリュームの値(AD値)を収集する。前回と同じ値なら0、異なる値なら1を返す。 このルーチンではビット境界での振動を排除するアルゴリズムを搭載する。 */ GetVolumeValue() { int chgf; chgf=0; VOLc=BALc=S1c=S2c=S3c=S4c=0; if(VR_FLAG) VOL = get_ad4(0); /* main volume */ if(ENCORDER_FLAG) EncorderCheck(); BAL = get_ad4(1); /* Balance control */ S1 = get_ad4(2); /* Level offset of S1*/ S2 = get_ad4(3); /* Level offset of S2*/ S3 = get_ad4(4); /* Level offset of S3*/ S4 = get_ad4(5); /* Level offset of S4*/ if(VR_FLAG) GetVolumeValueSub(&VOL,&VOLp,&VOLd,&chgf,&VOLc); else if(VOLc) chgf=1; GetVolumeValueSub(&BAL,&BALp,&BALd,&chgf,&BALc); GetVolumeValueSub(&S1,&S1p,&S1d,&chgf,&S1c); GetVolumeValueSub(&S2,&S2p,&S2d,&chgf,&S2c); GetVolumeValueSub(&S3,&S3p,&S3d,&chgf,&S3c); GetVolumeValueSub(&S4,&S4p,&S4d,&chgf,&S4c); return(chgf); } GetVolumeValueSub(a,ap,ad,f,c) int *a,*ap,*ad,*f,*c; { if(*ad==1){ if(*a>*ap){*ap = *a;*c=1;} else {if((*a-*ap)<-1) {*ad=0;*ap = *a;*c=1;}} }else{ if(*a<*ap){*ap = *a;*c=1;} else {if((*a-*ap)>1) {*ad=0;*ap = *a;*c=1;} } } if(*c) *f=1; else *a=*ap; } /* エンコーダチェック(加速制御有り) */ #define ACC_CONST (300) EncorderCheck() { int p,inc; if(ENCwait557) ENC=557; VOLc=1; ENCwait=1; } /**************** main routine *****************/ void main(void) { int i,j; int disp0,disp1; InitializeADC(); /* ADコンバータ初期化 */ PORT_INITIALIZE(); /* IOポート初期化 */ WaitLong(); /* LCD電源安定化待ち */ InitializeParameter(); /* 各種パラメータの初期化 */ GrLCD_ON(); /* LCD 表示 */ GrLCD_CLEAR(); GrLCD_check(); /* LCDのテスト表示 */ WaitLong(); /* MUTE解除時間待ち */ GrLCD_CLEAR(); for(i=0;i<8;i++) SOUT16_CN5(7,0);/* 音量初期設定:ゼロ */ *padr = *pbdr = 0x10; /* MUTE 解除 */ SetAttenuation(); /* 減衰量計算(初期VR値から換算) */ Send_ATT_Data(); /* 減衰値設定 データを送信*/ disp1=*p5dr&0x02; VOLc=BALc=S1c=S2c=S3c=S4c=1; if(disp1){ DispFormat1(); /* 表示パターン1 */ DispDataWithFormat1(); } else{ DispFormat3(); /* 表示パターン3 */ DispDataWithFormat3(); } while(1){ if(GetVolumeValue()){ /* ボリューム値の取得 */ SetAttenuation(); /* 各ボードの減衰量計算 */ Send_ATT_Data(); /* 減衰値設定 データを送信*/ LED_DISP2(); } disp0=*p5dr&0x02; /* 表示切り替え */ if(disp1!=disp0){ if(j) DispFormat1(); else DispFormat3(); VOLc=BALc=S1c=S2c=S3c=S4c=1; disp1=disp0; } if(i) DispDataWithFormat1(); else DispDataWithFormat3(); } }