---
# System prepended metadata

title: 微處理機2
tags: [Coding]

---

# 雞巴微處理機2
[雞巴微處理機](https://hackmd.io/iT31nBwUSdOHDK9IqdN6CA)
## 第一次上機考
ShowSevenSegment有修改
```cpp=
void ShowSevenSegment(int p, int n){
    if(n==10){
        //亮負號
    }
    //其他不變
}
```
```cpp=
#include <stdio.h>

// 顯示整數在四個七段顯示器上
void Display_7seg(int value) {
    int digit, highDigit, i;

    if (value > 0) {
        // 測試最高位是幾位數
        if (value / 1000 != 0) {
            highDigit = 3;
        } else if (value / 100 != 0) {
            highDigit = 2;
        } else if (value / 10 != 0) {
            highDigit = 1;
        } else {
            highDigit = 0;
        }
    }

    // 顯示千位數
    digit = value / 1000;
    if (3 < highDigit + 1) {
        CloseSevenSegment();    // 關閉顯示器
        ShowSevenSegment(3, digit);  // 顯示千位數
        CLK_SysTickDelay(5000);      // 延遲 5000 時鐘
    }

    // 顯示百位數
    value = value - digit * 1000;
    digit = value / 100;
    if (2 < highDigit + 1) {
        CloseSevenSegment();
        ShowSevenSegment(2, digit);  // 顯示百位數
        CLK_SysTickDelay(5000);
    }

    // 顯示十位數
    value = value - digit * 100;
    digit = value / 10;
    if (1 < highDigit + 1) {
        CloseSevenSegment();
        ShowSevenSegment(1, digit);  // 顯示十位數
    }

    // 顯示個位數
    value = value - digit * 10;
    digit = value;
    CloseSevenSegment();
    ShowSevenSegment(0, digit);      // 顯示個位數
    
    後面有另外顯示負號的程式但沒截到
    ShowSevenSegment( n, 10);顯示負號的方式
}

int main(void) {
    int i, sum = 0, j;

    SYS_Init();                // 系統初始化
    OpenSevenSegment();        // 開啟七段顯示器
    OpenKeyPad();              // 開啟鍵盤

    while(1) {
        i = ScanKey();         // 掃描鍵盤按鍵
        if (i == 1) {
            sum -= 10;         // 如果按下按鍵 1，sum 減 10
        } else if (i == 3) {
            sum += 10;         // 如果按下按鍵 3，sum 加 10
        } else if (i == 4) {
            sum--;             // 如果按下按鍵 4，sum 減 1
        } else if (i == 6) {
            sum++;             // 如果按下按鍵 6，sum 加 1
        } else if (i == 8) {
            sum = 0;           // 如果按下按鍵 8，將 sum 重置為 0
        }

        if (sum < -128) {      // 若 sum 小於 -128，進行調整
            sum = 128 - (-sum % 128);
        }

        if (sum > 127) {       // 若 sum 大於 127，進行調整
            sum = -129 + (sum % 127);
        }

        for (j = 0; j < 15; j++) {
            Display_7seg(sum);  // 將 sum 顯示在七段顯示器上
        }
    }
}
```
## 第二次上機考
![IMG_5547](https://hackmd.io/_uploads/rJJUkPJVJx.jpg =80%x)
![close](https://hackmd.io/_uploads/HkRW9DN8kx.bmp)
![half](https://hackmd.io/_uploads/SkRW9w4IJl.bmp)
![open](https://hackmd.io/_uploads/rJR-5v4U1g.bmp)

第三題
```cpp=
#include <stdio.h>
#include "NUC100Series.h"
#include "MCU_init.h"
#include "SYS_init.h"
#include "LCD.h"

int hold=0;

unsigned char map1[128*8] = { // TCFST Logo 
		0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
	, 	0x00,0x00,0x04,0x0C,0x0C,0x18,0x30,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x18,0x18,0x0C,0x0C,0x04,0x00,0x00,0xFC,0x7C,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x7C,0xFC,0x00,0x00,0x04,0x0C,0x0C,0x18,0x18,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x30,0x18,0x0C,0x0C,0x04,0x00,0x00
	, 	0x00,0x00,0x88,0xCC,0xCC,0x66,0x33,0x13,0x19,0xFF,0x8F,0xFF,0x19,0x33,0x66,0x66,0xCC,0xCC,0x88,0x00,0x00,0xFF,0x78,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x78,0xFF,0x00,0x00,0x88,0xCC,0xCC,0x66,0x66,0x33,0x19,0xFF,0x8F,0xFF,0x19,0x13,0x33,0x66,0xCC,0xCC,0x88,0x00,0x00
	, 	0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00,0xFF,0x78,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x40,0x40,0xC0,0xC0,0x40,0x40,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x78,0xFF,0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00
	, 	0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xC2,0x81,0x00,0xF8,0xCF,0x98,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x36,0xEA,0x5B,0x6C,0xB9,0xF6,0xE9,0xD7,0xFA,0xFA,0xD7,0xE9,0xF6,0xB9,0x6C,0x5B,0xEA,0x36,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3F,0x98,0xCF,0xF8,0x00,0x81,0xC2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20
	, 	0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xCC,0x99,0x33,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x11,0x09,0x08,0x09,0x0B,0x0F,0x0F,0x0F,0x0F,0x0B,0x09,0x08,0x09,0x11,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x33,0x99,0xCC,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00
	, 	0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFF,0x7C,0xF9,0x73,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x73,0xF9,0x7C,0xFF,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0
	, 	0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA
};

unsigned char map2[128*8] = { // TCFST Logo 
		0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
	, 	0x00,0x00,0x04,0x0C,0x0C,0x18,0x30,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x18,0x18,0x0C,0x0C,0x04,0x00,0x00,0xFC,0x7C,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0C,0x0C,0x18,0x18,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x30,0x18,0x0C,0x0C,0x04,0x00,0x00
	, 	0x00,0x00,0x88,0xCC,0xCC,0x66,0x33,0x13,0x19,0xFF,0x8F,0xFF,0x19,0x33,0x66,0x66,0xCC,0xCC,0x88,0x00,0x00,0xFF,0x78,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x1E,0x3C,0x78,0xF0,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0xCC,0xCC,0x66,0x66,0x33,0x19,0xFF,0x8F,0xFF,0x19,0x13,0x33,0x66,0xCC,0xCC,0x88,0x00,0x00
	, 	0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x60,0xFF,0x78,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x40,0x40,0xC0,0xC0,0x40,0x40,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x0F,0x1E,0x3C,0x48,0x90,0x20,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00
	, 	0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xC2,0x81,0x00,0xF8,0xCF,0x98,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x36,0xEA,0x5B,0x6C,0xB9,0xF6,0xE9,0xD7,0xFA,0xFA,0xD7,0xE9,0xF6,0xB9,0x6C,0x5B,0xEA,0x36,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x12,0x24,0xF8,0x38,0x98,0xC8,0xF8,0x80,0x81,0xC2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20
	, 	0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xCC,0x99,0x33,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x11,0x09,0x08,0x09,0x0B,0x0F,0x0F,0x0F,0x0F,0x0B,0x09,0x08,0x09,0x11,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x33,0x99,0xCC,0xFF,0xFE,0x01,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00
	, 	0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFF,0x7C,0xF9,0x73,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x73,0xF9,0x7C,0xFF,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0
	, 	0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA
};

unsigned char map3[128*8] = { // TCFST Logo 
		0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
	, 	0x00,0x00,0x04,0x0C,0x0C,0x18,0x30,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x18,0x18,0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0C,0x0C,0x18,0x18,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x30,0x18,0x0C,0x0C,0x04,0x00,0x00
	, 	0x00,0x00,0x88,0xCC,0xCC,0x66,0x33,0x13,0x19,0xFF,0x8F,0xFF,0x19,0x33,0x66,0x66,0xCC,0xCC,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0xF0,0x78,0x3C,0x1E,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0xCC,0xCC,0x66,0x66,0x33,0x19,0xFF,0x8F,0xFF,0x19,0x13,0x33,0x66,0xCC,0xCC,0x88,0x00,0x00
	, 	0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x20,0x90,0x48,0x3C,0x1E,0x0F,0x04,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x40,0x40,0xC0,0xC0,0x40,0x40,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00
	, 	0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xC2,0x81,0x80,0xF8,0xC8,0x98,0x38,0xF8,0x24,0x12,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x36,0xEA,0x5B,0x6C,0xB9,0xF6,0xE9,0xD7,0xFA,0xFA,0xD7,0xE9,0xF6,0xB9,0x6C,0x5B,0xEA,0x36,0x18,0x00,0x00,0x00,0xE0,0xE0,0xE0,0xE0,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xE0,0xE0,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xE0,0xE0,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xF8,0x38,0x98,0xC8,0xF8,0xA0,0xA1,0xE2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20
	, 	0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x01,0xFE,0xFF,0xCC,0x99,0x33,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x11,0x09,0x08,0x09,0x0B,0x0F,0x0F,0x0F,0x0F,0x0B,0x09,0x08,0x09,0x11,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x33,0x99,0xCC,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00
	, 	0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFF,0x7C,0xF9,0x73,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x73,0xF9,0x7C,0xFF,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0
	, 	0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA
};
unsigned char map4[128*8] = { // TCFST Logo 
		0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
	, 	0x00,0x00,0x04,0x0C,0x0C,0x18,0x30,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x18,0x18,0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0C,0x0C,0x18,0x18,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x30,0x18,0x0C,0x0C,0x04,0x00,0x00
	, 	0x00,0x00,0x88,0xCC,0xCC,0x66,0x33,0x13,0x19,0xFF,0x8F,0xFF,0x19,0x33,0x66,0x66,0xCC,0xCC,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0xCC,0xCC,0x66,0x66,0x33,0x19,0xFF,0x8F,0xFF,0x19,0x13,0x33,0x66,0xCC,0xCC,0x88,0x00,0x00
	, 	0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x40,0x40,0xC0,0xC0,0x40,0x40,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00
	, 	0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xE2,0xA1,0xA0,0xF8,0xC8,0x98,0x38,0xF8,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xE0,0xE0,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xE0,0xE0,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xE0,0xE0,0xE0,0xE0,0x00,0x00,0x00,0x18,0x36,0xEA,0x5B,0x6C,0xB9,0xF6,0xE9,0xD7,0xFA,0xFA,0xD7,0xE9,0xF6,0xB9,0x6C,0x5B,0xEA,0x36,0x18,0x00,0x00,0x00,0xE0,0xE0,0xE0,0xE0,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xE0,0xE0,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xE0,0xE0,0xE0,0xA0,0xA0,0xA0,0xA0,0xE0,0xF8,0x38,0x98,0xC8,0xF8,0xA0,0xA1,0xE2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20
	, 	0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xCC,0x99,0x33,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x11,0x09,0x08,0x09,0x0B,0x0F,0x0F,0x0F,0x0F,0x0B,0x09,0x08,0x09,0x11,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x33,0x99,0xCC,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00
	, 	0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFF,0x7C,0xF9,0x73,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x73,0xF9,0x7C,0xFF,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0
	, 	0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA
};

unsigned char map5[128*8] = { // TCFST Logo 
		0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
	, 	0x00,0x00,0x04,0x0C,0x0C,0x18,0x30,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x18,0x18,0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0C,0x0C,0x18,0x18,0x30,0xE0,0xE0,0xC0,0xE0,0xE0,0x30,0x30,0x18,0x0C,0x0C,0x04,0x00,0x00
	, 	0x00,0x00,0x88,0xCC,0xCC,0x66,0x33,0x13,0x19,0xFF,0x8F,0xFF,0x19,0x33,0x66,0x66,0xCC,0xCC,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0xF0,0x78,0x3C,0x1E,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x1E,0x3C,0x78,0xF0,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0xCC,0xCC,0x66,0x66,0x33,0x19,0xFF,0x8F,0xFF,0x19,0x13,0x33,0x66,0xCC,0xCC,0x88,0x00,0x00
	, 	0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x20,0x90,0x48,0x3C,0x1E,0x0F,0x04,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x40,0x40,0xC0,0xC0,0x40,0x40,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x0F,0x1E,0x3C,0x48,0x90,0x20,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x3C,0x24,0xC4,0x04,0x04,0xFF,0x87,0xFF,0x04,0x04,0xC4,0x24,0x3C,0x20,0xC0,0x00,0x00
	, 	0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xC2,0x81,0x80,0xF8,0xC8,0x98,0x38,0xF8,0x24,0x12,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x36,0xEA,0x5B,0x6C,0xB9,0xF6,0xE9,0xD7,0xFA,0xFA,0xD7,0xE9,0xF6,0xB9,0x6C,0x5B,0xEA,0x36,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x12,0x24,0xF8,0x38,0x98,0xC8,0xF8,0x80,0x81,0xC2,0x22,0xE2,0x21,0xE0,0x20,0xFF,0x0F,0xFF,0x20,0xE0,0x21,0xE2,0x22,0xE2,0x21,0xE0,0x20
	, 	0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x01,0xFE,0xFF,0xCC,0x99,0x33,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x11,0x09,0x08,0x09,0x0B,0x0F,0x0F,0x0F,0x0F,0x0B,0x09,0x08,0x09,0x11,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x33,0x99,0xCC,0xFF,0xFE,0x01,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x1F,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00
	, 	0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFF,0x7C,0xF9,0x73,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xF0,0x70,0xFF,0x73,0xF9,0x7C,0xFF,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xFC,0x7F,0xFE,0x7F,0xFC,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0,0x7F,0xF0
	, 	0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA
};

void Display_7seg(uint16_t value)
{
    uint8_t digit;
    digit = value / 10;
    CloseSevenSegment();
    ShowSevenSegment(1,digit);
    CLK_SysTickDelay(5000);

    value = value - digit * 10;
    digit = value;
    CloseSevenSegment();
    ShowSevenSegment(0,digit);
    CLK_SysTickDelay(5000);
}

void EINT1_IRQHandler(void)
{
    GPIO_CLR_INT_FLAG(PB, BIT15);	// Clear GPIO interrupt flag
		hold=1;
}

void Init_EXTINT(void)
{
    // Configure EINT1 pin and enable interrupt by rising and falling edge trigger
    GPIO_SetMode(PB, BIT15, GPIO_MODE_INPUT);
    GPIO_EnableEINT1(PB, 15, GPIO_INT_RISING); // RISING, FALLING, BOTH_EDGE, HIGH, LOW
    NVIC_EnableIRQ(EINT1_IRQn);

    // Enable interrupt de-bounce function and select de-bounce sampling cycle time
    GPIO_SET_DEBOUNCE_TIME(GPIO_DBCLKSRC_LIRC, GPIO_DBCLKSEL_64);
    GPIO_ENABLE_DEBOUNCE(PB, BIT15);
}

int32_t main()
{	
    int i,j,leftsecond=0;
    SYS_Init();
		init_LCD();
		clear_LCD();
    OpenSevenSegment();
    Init_EXTINT();
		draw_LCD(map1);
    while(1){
			Display_7seg(leftsecond);
      if(hold==1){
				leftsecond=10;
				draw_LCD(map2);
				for(j=0;j<100;j++)Display_7seg(leftsecond);
				
				draw_LCD(map3);
				for(j=0;j<100;j++)Display_7seg(leftsecond);
				
				draw_LCD(map4);
				for(j=0;j<100;j++)Display_7seg(leftsecond);
				
				//do
				for(i=0;i<5;i++){
					PC12=0;
					PC15=1;
					for(j=0;j<50;j++)Display_7seg(leftsecond);
					PC12=1;
					PC15=0;
					for(j=0;j<50;j++)Display_7seg(leftsecond);
					leftsecond--;
					
					PC12=0;
					PC15=1;
					for(j=0;j<50;j++)Display_7seg(leftsecond);
					PC12=1;
					PC15=0;
					for(j=0;j<50;j++)Display_7seg(leftsecond);
					leftsecond--;
				}
				PC12=1;
				PC15=1;
				for(j=0;j<100;j++)Display_7seg(leftsecond);
				
				draw_LCD(map5);
				for(j=0;j<100;j++)Display_7seg(leftsecond);
				
				draw_LCD(map1);
				for(j=0;j<100;j++)Display_7seg(leftsecond);
				hold=0;
				leftsecond=0;
			}
    }
}

```
## PCB加分
主程式
```c
//
// GPIO_7seg_keypad4 : keypad input 4 digits and display on 7-segment LEDs
//
#include <stdio.h>
#include <math.h>
#include "NUC100Series.h"
#include "MCU_init.h"
#include "SYS_init.h"
#include "Seven_Segment.h"
#include "Scankey.h"


void init_GPIO(){
	GPIO_SetMode(PA,BIT12,GPIO_MODE_OUTPUT);
	GPIO_SetMode(PA,BIT13,GPIO_MODE_OUTPUT);
	GPIO_SetMode(PA,BIT14,GPIO_MODE_OUTPUT);
	PA12=1;
	PA13=1;
	PA14=1;
	
}

int main(void)
{
	int i=3;
	int j=0;
	int k=0;
	int s=0;
	int code;	
	
        SYS_Init();
        GPIO_SetMode(PE, BIT0, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT1, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT2, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT3, GPIO_PMD_OUTPUT);	
	GPIO_SetMode(PE, BIT4, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT5, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT6, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT7, GPIO_PMD_OUTPUT);
    //OpenSevenSegment();
	  OpenKeyPad();

 	  while(1) {
			PA12=1;
			PA13=0;
			PA14=0;
			for(i=0;i<5;i++){
				ShowSevenSegment(0, i+1);
				CLK_SysTickDelay(1000000);
				CLK_SysTickDelay(1000000);
				CLK_SysTickDelay(1000000);
			}
			
			PA12=0;
			PA13=1;
			PA14=0;
			
			PE0=0;
			PE1=0;
			PE2=0;
			PE3=0;
			PE4=0;
			PE5=0;
			PE6=0;
			PE7=0;
			CLK_SysTickDelay(1000000);
			CLK_SysTickDelay(1000000);
			CLK_SysTickDelay(1000000);
			
		        PA12=0;
			PA13=0;
			PA14=1;
			for(i=0;i<5;i++){
				ShowSevenSegment(0, i+1);
				CLK_SysTickDelay(1000000);
				CLK_SysTickDelay(1000000);
				CLK_SysTickDelay(1000000);
			}
			
			PA12=0;
			PA13=1;
			PA14=0;
			PE0=0;
                       PE1=0;
                       PE2=0;
                       PE3=0;
                       PE4=0;
                       PE5=0;
                       PE6=0;
                       PE7=0;
			CLK_SysTickDelay(1000000);
				CLK_SysTickDelay(1000000);
				CLK_SysTickDelay(1000000);
			
			
	  }
}

```
七段
```c
#include <stdio.h>
#include "NUC100Series.h"
#include "GPIO.h"
#include "SYS.h"
#include "Seven_Segment.h"
#define SEG_N0   0x82 
#define SEG_N1   0xEE 
#define SEG_N2   0x07 
#define SEG_N3   0x46 
#define SEG_N4   0x6A  
#define SEG_N5   0x52 
#define SEG_N6   0x12 
#define SEG_N7   0xE6 
#define SEG_N8   0x02 
#define SEG_N9   0x62
#define SEG_N10	 0x22
#define SEG_N11  0x1A
#define SEG_N12  0x93
#define SEG_N13  0x0E
#define SEG_N14  0x13
#define SEG_N15  0x33

uint8_t SEG_BUF[16]={SEG_N0, SEG_N1, SEG_N2, SEG_N3, SEG_N4, SEG_N5, SEG_N6, SEG_N7, SEG_N8, SEG_N9, SEG_N10, SEG_N11, SEG_N12, SEG_N13, SEG_N14, SEG_N15}; 
void OpenSevenSegment(void)
{
	GPIO_SetMode(PC, BIT4, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PC, BIT5, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PC, BIT6, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PC, BIT7, GPIO_PMD_OUTPUT);
	PC4=1;
	PC5=1;
	PC6=1;
	PC7=1;
	GPIO_SetMode(PE, BIT0, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT1, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT2, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT3, GPIO_PMD_OUTPUT);	
	GPIO_SetMode(PE, BIT4, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT5, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT6, GPIO_PMD_OUTPUT);
	GPIO_SetMode(PE, BIT7, GPIO_PMD_OUTPUT);
        PE0=0;
        PE1=0;
        PE2=0;
	PE3=0;
	PE4=0;
	PE5=0;
	PE6=0;
	PE7=0;
}

void ShowSevenSegment(uint8_t no, uint8_t number)
{
  uint8_t temp,i;
	temp=SEG_BUF[number];
	
	for(i=0;i<8;i++)
	    {
		if((temp&0x01)==0x01)		   		   
			 switch(i) {
				 case 0: PE0=0; break;
				 case 1: PE1=0; break;
				 case 2: PE2=0; break;
				 case 3: PE3=0; break;
				 case 4: PE4=0; break;
				 case 5: PE5=0; break;
				 case 6: PE6=0; break;
				 case 7: PE7=0; break;
			   }		
		   else
				 switch(i) {
				 case 0: PE0=1; break;
				 case 1: PE1=1; break;
				 case 2: PE2=1; break;
				 case 3: PE3=1; break;
				 case 4: PE4=1; break;
				 case 5: PE5=1; break;
				 case 6: PE6=1; break;
				 case 7: PE7=1; break;
				 }	  
		   temp=temp>>1;
		}
			switch(no) {
				case 0: PC4=1; break;
				case 1: PC5=1; break;
				case 2: PC6=1; break;
				case 3: PC7=1; break;
			}
}

void CloseSevenSegment(void)
{
	PC4=0;	
	PC5=0;	
	PC6=0;	
	PC7=0;
}
```

## 9/27
:::spoiler
# Lab 2 - GPIO (Buzzer)
## 題目 1 - 播放音樂
按下 P 鍵，播放 *Kirby Dance (Short)* （下面的旋律）一次。
![image](https://hackmd.io/_uploads/SJQw6jQ00.png)

| pitch | duration |
|-------|----------|
| F4    | 0.333333 |
| G4    | 0.333333 |
| A4    | 0.333333 |
| B4    | 0.333333 |
| A4    | 0.333333 |
| B4    | 0.333333 |
| C5    | 0.333333 |
| rest  | 0.333333 |
| G4    | 0.333333 |
| E4    | 0.333333 |
| rest  | 0.333333 |
| G5    | 0.333333 |
| F5    | 0.333333 |
| rest  | 0.333333 |
| E5    | 0.333333 |
| D5    | 0.333333 |
| rest  | 0.333333 |
| E5    | 0.333333 |
| C5    | 1        |
| C6    | 0.5      |
| rest  | 0.5      |

###### p.s. It's normal that it sounds bad when playing on NUC-140.

### 音高頻率表
![](https://dobrian.github.io/cmp/topics/physics-of-sound/1.freqpitchtable.png)

### 鍵位配置
```
┌───┬───┬───┐
│   │   │   │
├───┼───┼───┤
│   │ P │   │
├───┼───┼───┤
│   │   │   │
└───┴───┴───┘
```
---
## 題目 2 - 3~ 2~ 1~ BOOM
使用 Keypad、LED 與蜂鳴器搭配實作出引爆炸彈的效果。
- LED 預設狀態為 全部不亮。
- 蜂鳴器 預設狀態為 不發出聲響。
- 按下 D (Detonate) 來開始倒數計時。
- 按下 D 後 LED 全亮並依序由左至右一個一個暗掉。
- 最後一個(最右邊) LED 暗掉的同時蜂鳴器發出聲響以表示爆炸。
- 按下 C (Cancel) 直接取消引爆( LED 和蜂鳴器街回到預設狀態)。
- 蜂鳴器在引爆後會一直響直到按下 C 。
- 不需按照秒數(跟上禮拜的一樣)。
#### 範例
- □為暗。
- ■為亮。
 
| t            | pattern | input|buzzer |
|-------------|---------|-------|-------|
|    0        | □□□□    |  D    |       |
|    1        | ■■■■    |  C    |       |
|    2        | □□□□    |  D    |       |
|    3        | ■■■■    |       |       |
|    5        | □■■■    |       |       |
|    6        | □□■■    |       |       |
|    7        | □□□■    |       |       |
|    8        | □□□□    |       |🔊🔊🔊|
|    9        | □□□□    |  C    |       |
| ...         | ...     |...    |       |
| n           | ...     |...    |       |

### 鍵位配置
```
┌───┬───┬───┐
│   │ D │   │
├───┼───┼───┤
│   │   │   │
├───┼───┼───┤
│   │ C │   │
└───┴───┴───┘
```
---
## 題目 3 - 節拍器(一)
- P 鍵啟動／停止節拍器的運作，預設停止。在運作時以 BPM 120 (每 0.5 秒一拍)的速度執行。
- M 鍵開啟／關閉節拍器的聲音，預設開啟。若設定為開，在運作時跟著拍點短響一聲。
- L 鍵開啟／關閉節拍器燈光，預設開啟。若設定為開，在運作時 LED5 跟著拍點閃爍。
- 將 P、M、L 的狀態分別對應到 LED6~LED8 上(開啟時亮)。

### 鍵位配置
```
┌───┬───┬───┐
│   │   │   │
├───┼───┼───┤
│ P │ M │ L │
├───┼───┼───┤
│   │   │   │
└───┴───┴───┘
```

---

:::
### 第一題
```cpp=
#include <stdio.h>
#include "NUC100Series.h"
#include "MCU_init.h"
#include "SYS_init.h"
#define p333 333000
#define p1000 1000000
#define p500 5000000
#define F4 2864
#define G4 2551
#define A4 2273
#define B4 2025
#define C5 1907
#define E4 3032
#define G5 1278
#define F5 1430
#define D5 1701
#define E5 1515
#define C6 954
#define rest 0
#define t3 333333
#define t5 500000
#define t10 1000000

void Buzz()
{
	int i,cnt,j;
	int tone[100]={F4,G4,A4,B4,A4,B4,C5,rest,G4,E4,rest,G5,F5,rest,E5,D5,rest,E5,C5,C6,rest};
	for (i=0; i<18; i++) {
		if(tone[i]==rest){
			CLK_SysTickDelay(t3);	 // Delay 
			continue;
		}
		cnt=t3/(tone[i]);
		for(j=0;j<cnt;j++){
			PB11=0; // PB11 = 0 to turn on Buzzer
			CLK_SysTickDelay(tone[i]/2);	 // Delay 
			PB11=1; // PB11 = 1 to turn off Buzzer	
			CLK_SysTickDelay(tone[i]/2);	 // Delay 
		}
	}
	for(i=0;i<1;i++){
		if(tone[i]==rest){
			CLK_SysTickDelay(t3);	 // Delay 
			continue;
		}
		cnt=t10/(tone[i]);
		for(j=0;j<cnt;j++){
			PB11=0; // PB11 = 0 to turn on Buzzer
			CLK_SysTickDelay(tone[i]/2);	 // Delay 
			PB11=1; // PB11 = 1 to turn off Buzzer	
			CLK_SysTickDelay(tone[i]/2);	 // Delay 
		}
	}
	for(i=0;i<2;i++){
		if(tone[i]==rest){
			CLK_SysTickDelay(t3);	 // Delay 
			continue;
		}
		cnt=t5/(tone[i]);
		for(j=0;j<cnt;j++){
			PB11=0; // PB11 = 0 to turn on Buzzer
			CLK_SysTickDelay(tone[i]/2);	 // Delay 
			PB11=1; // PB11 = 1 to turn off Buzzer	
			CLK_SysTickDelay(tone[i]/2);	 // Delay 
		}
	}
}

int32_t main (void){
    int sk;
    SYS_Init();
    GPIO_SetMode(PB, BIT11, GPIO_MODE_OUTPUT);
    while(1){
        sk=ScanKey();
        if(sk==5)Buzz(); 
    }
}

```

### 第二題
```c=
int32_t main (void)
{
		int sk,start=0,status=4;
    SYS_Init();
	  GPIO_SetMode(PB, BIT11, GPIO_MODE_OUTPUT);
	  GPIO_SetMode(PC, BIT12, GPIO_MODE_OUTPUT);
		while(1){
			sk=ScanKey();
			if(sk==2)start=1;
			if(sk==8){
				start=0;
				PB11=1;
				status=4;
				PC12=1;
				PC13=1;
				PC14=1;
				PC15=1;
			}
			if(start){
				if(status==4){
					PC12=0;
					PC13=0;
					PC14=0;
					PC15=0;
					CLK_SysTickDelay(1000000);
					status--;
				}else if(status==3){
					PC12=1;
					CLK_SysTickDelay(1000000);
					status--;
				}else if(status==2){
					PC12=1;
					PC13=1;
					CLK_SysTickDelay(1000000);
					status--;
				}else if(status==1){
					PC12=1;
					PC13=1;
					PC14=1;
					CLK_SysTickDelay(500000);
					status--;
				}else if(status<=0){
					PC12=1;
					PC13=1;
					PC14=1;
					PC15=1;
					PB11=0;
				}
			}
		}
}
```
### 第三題
```c=
//
// GPIO_Buzzer: GPIO output to drive Buzzer
//
// EVB : Nu-LB-NUC140
// MCU : NUC140VE3CN

// PB11 : NUC140 LQFP100 pin48

#include <stdio.h>
#include "NUC100Series.h"
#include "MCU_init.h"
#include "SYS_init.h"

// 		12 13 14 15
//led 5  6  7  8
int32_t main (void){
    int sk,Pstart=0,Mstart=1,Lstart=1,status=4,tempsk=0;
    SYS_Init();
	  GPIO_SetMode(PB, BIT11, GPIO_MODE_OUTPUT);
	  GPIO_SetMode(PC, BIT12, GPIO_MODE_OUTPUT);
		while(1){
			sk=ScanKey();
				if(tempsk!=sk && sk!=0){
					if(sk==4)Pstart=!Pstart;
					if(sk==5)Mstart=!Mstart;
					if(sk==6)Lstart=!Lstart;
				}
				if(Pstart)PC13=0;
				else PC13=1;
				if(Mstart)PC14=0;
				else PC14=1;
				if(Lstart)PC15=0;
				else PC15=1;
				
				if(Pstart!=0){
					if(Mstart)PB11=0;
					if(Lstart)PC12=0;
					CLK_SysTickDelay(100000);	 // Delay 
					if(Mstart)PB11=1;
					if(Lstart)PC12=1;
					CLK_SysTickDelay(900000);	 // Delay 
					CLK_SysTickDelay(500000);	 // Delay 
					CLK_SysTickDelay(30000);	 // Delay 
				}
			
			tempsk=sk;
		}
}
```

## 第三次上機考
![IMG_6109](https://hackmd.io/_uploads/ryKAZTvLkl.jpg)

```c=
#include <stdio.h>
#include <math.h>
#include "NUC100Series.h"
#include "MCU_init.h"
#include "SYS_init.h"
#include "LCD.h"
#include "Draw2D.h"
#include "Seven_Segment.h"

#define PI 3.14159265359

int16_t ADCvalue;
int16_t hold=0;

void EINT1_IRQHandler(void)
{
    GPIO_CLR_INT_FLAG(PB, BIT15);	// Clear GPIO interrupt flag
    hold=1;
}

void Init_EXTINT(void)
{
    // Configure EINT1 pin and enable interrupt by rising and falling edge trigger
    GPIO_SetMode(PB, BIT15, GPIO_MODE_INPUT);
    GPIO_EnableEINT1(PB, 15, GPIO_INT_RISING); // RISING, FALLING, BOTH_EDGE, HIGH, LOW
    NVIC_EnableIRQ(EINT1_IRQn);

    // Enable interrupt de-bounce function and select de-bounce sampling cycle time
    GPIO_SET_DEBOUNCE_TIME(GPIO_DBCLKSRC_LIRC, GPIO_DBCLKSEL_64);
    GPIO_ENABLE_DEBOUNCE(PB, BIT15);
}

void Draw_Spiral(uint16_t control_value) { //??2 ????? 

    int centerX = 64; // LCD ??? X
    int centerY = 32; // LCD ??? Y
    int maxRadius = 30; // ?? VR1 ??????
    float angleStep = 0.1; // ???????
    float theta,radius;
    int x,y;
    float rotationOffset = (control_value / 4096.0) * 4 * 3.14159 ; // 0 ~ 2p ???

    rotationOffset = (ADCvalue / 4096.0) * 4 * 3.14159; // 0 ~ 2p ???
    radius = maxRadius * rotationOffset / (6.28 * 2);
    x = centerX + radius * cos(rotationOffset);
    y = centerY - radius * sin(rotationOffset);
    draw_Pixel((int)x, (int)y,FG_COLOR,BG_COLOR); // ???
    draw_Rectangle(x-1, y-1, x+1, y+1, FG_COLOR, BG_COLOR);
}

void ADC_IRQHandler(void)
{
    uint32_t u32Flag;

    u32Flag = ADC_GET_INT_FLAG(ADC, ADC_ADF_INT);
    if(u32Flag & ADC_ADF_INT) {
    ADCvalue = ADC_GET_CONVERSION_DATA(ADC, 7);

            if(hold==1){
                clear_LCD();
                hold=0;
            }
            Draw_Spiral(ADCvalue);
    }
    ADC_CLR_INT_FLAG(ADC, u32Flag);
}

void Init_ADC(void)
{
    ADC_Open(ADC, ADC_INPUT_MODE, ADC_OPERATION_MODE, ADC_CHANNEL_MASK);
    ADC_POWER_ON(ADC);
    ADC_EnableInt(ADC, ADC_ADF_INT);
    NVIC_EnableIRQ(ADC_IRQn);
    ADC_START_CONV(ADC);
}

int32_t main(void)
{
    SYS_Init();
    init_LCD();
    clear_LCD();
    Init_ADC();
    OpenSevenSegment();
    Init_EXTINT();
    while(1) {
        // ???????,?????ADC????
    }
}
```

```c
#include <stdio.h>
#include <math.h>
#include "NUC100Series.h"
#include "MCU_init.h"
#include "SYS_init.h"
#include "LCD.h"
#include "Draw2D.h"
#include "Seven_Segment.h"

// ????
char Text[16];
int angleInt;
int16_t ADCvalue;
int16_t preADCvalue=0;
int16_t hold=0;

#define PI 3.14159265359
#define SEESAW_LENGTH 80  // ?????
#define CENTER_X 64       // LCD???X
#define CENTER_Y 32       // LCD???Y



void EINT1_IRQHandler(void)
{
    GPIO_CLR_INT_FLAG(PB, BIT15);	// Clear GPIO interrupt flag
		hold=1;
}

void Init_EXTINT(void)
{
    // Configure EINT1 pin and enable interrupt by rising and falling edge trigger
    GPIO_SetMode(PB, BIT15, GPIO_MODE_INPUT);
    GPIO_EnableEINT1(PB, 15, GPIO_INT_RISING); // RISING, FALLING, BOTH_EDGE, HIGH, LOW
    NVIC_EnableIRQ(EINT1_IRQn);

    // Enable interrupt de-bounce function and select de-bounce sampling cycle time
    GPIO_SET_DEBOUNCE_TIME(GPIO_DBCLKSRC_LIRC, GPIO_DBCLKSEL_64);
    GPIO_ENABLE_DEBOUNCE(PB, BIT15);
}

void Draw_Spiral(uint16_t control_value) { //??2 ????? 

    int centerX = 64; // LCD ??? X
    int centerY = 32; // LCD ??? Y
    int maxRadius = 30; // ?? VR1 ??????
    float angleStep = 0.1; // ???????
		float theta,radius;
		int x,y;
		float rotationOffset = (control_value / 4096.0) * 4 * 3.14159; // 0 ~ 2p ???
		clear_LCD();
		
    for ( theta = 0; theta < 6.28 * 2; theta += angleStep) { // ????
         radius = maxRadius * theta / (6.28 * 2);
         x = centerX + radius * cos(theta+rotationOffset);
         y = centerY + radius * sin(theta+rotationOffset);

        draw_Pixel((int)x, (int)y,FG_COLOR,BG_COLOR); // ???
				draw_Rectangle(x-1, y-1, x+1, y+1, FG_COLOR, BG_COLOR);
    }
}


void ADC_IRQHandler(void)
{
    uint32_t u32Flag;
    
    int centerX = 64; // LCD ??? X
    int centerY = 32; // LCD ??? Y
    int maxRadius = 30; // ?? VR1 ??????
    //float angleStep = 0.1; // ???????
    float theta,radius;
    int x,y;
    float rotationOffset; // 0 ~ 2p ???
	
    u32Flag = ADC_GET_INT_FLAG(ADC, ADC_ADF_INT);
    if(u32Flag & ADC_ADF_INT) {
    ADCvalue = ADC_GET_CONVERSION_DATA(ADC, 7);
    //AngleMeasurement(ADCvalue);

            if(hold==1){
                clear_LCD();

                rotationOffset = (ADCvalue / 4096.0) * 4 * 3.14159; // 0 ~ 2p ???
                radius = maxRadius * rotationOffset / (6.28 * 2);
                x = centerX + radius * cos(rotationOffset*2);
                y = centerY + radius * sin(rotationOffset*2);
                draw_Pixel((int)x, (int)y,FG_COLOR,BG_COLOR); // ???
                draw_Rectangle(x-1, y-1, x+1, y+1, FG_COLOR, BG_COLOR);


                hold=0;
            }
            if(ADCvalue > preADCvalue+200 || ADCvalue < preADCvalue-200 ){

                Draw_Spiral(ADCvalue);
                preADCvalue=ADCvalue;
            }
    }
    ADC_CLR_INT_FLAG(ADC, u32Flag);
}

void Init_ADC(void)
{
    ADC_Open(ADC, ADC_INPUT_MODE, ADC_OPERATION_MODE, ADC_CHANNEL_MASK);
    ADC_POWER_ON(ADC);
    ADC_EnableInt(ADC, ADC_ADF_INT);
    NVIC_EnableIRQ(ADC_IRQn);
    ADC_START_CONV(ADC);
}

int32_t main(void)
{
    SYS_Init();
    init_LCD();
    clear_LCD();
    Init_ADC();
    OpenSevenSegment();
    Init_EXTINT();
    while(1) {
        // ???????,?????ADC????
    }
}

```