⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 用ATmega8 做的MP3播放器
💻 C
字号:
#include <avr/io.h>
#include <avr/signal.h>
#include <avr/interrupt.h>

#include "vs1001.h"
#include "test.h"
#include "types.h"
#include "config.h"
#include "delay.h"

#define FREQ 0x30

#define LED_ON   { cbi(LED_PORT, LED_PLAY_PIN); /*VS1001_sine(0x01, FREQ);*/ }
#define LED_OFF  { sbi(LED_PORT, LED_PLAY_PIN); /*VS1001_sine(0x00, 0x00);*/ }

void dot(void)
{ LED_ON;
  delay_ms(200);
  LED_OFF;
  delay_ms(600);
}

void dash(void)
{ LED_ON;
  delay_ms(800);
  LED_OFF;
  delay_ms(200);
}

void blink_start(void)
{ LED_OFF;
  delay_ms(400);
}

void blink_end(void)
{ u08 i;

  for (i=0; i<4; i++)
  { LED_ON;
    delay_ms(200);
    LED_OFF;
    delay_ms(200);
  }
  delay_ms(400);
}

void blink_error(void)
{ while(1)
  { LED_ON;
    delay_ms(200);
    LED_OFF;
    delay_ms(200);
  }
}

void blink(u08 x)
{ switch(x)
  { case 'A':
    case 'a':
    case 10:
      dot(); dash(); break;
    case 'B':
    case 'b':
    case 11:
      dash(); dot(); dot(); dot(); break;
    case 'C':
    case 'c':
    case 12:
      dash(); dot(); dash(); dot(); break;
    case 'D':
    case 'd':
    case 13:
      dash(); dot(); dot(); break;
    case 'E':
    case 'e':
    case 14:
      dot(); break;
    case 'F':
    case 'f':
    case 15:
      dot(); dot(); dash(); dot(); break;
    case 'G':
    case 'g':
      dash(); dash(); dot(); break;
    case 'H':
    case 'h':
      dot(); dot(); dot(); dot(); break;
    case 'I':
    case 'i':
      dot(); dot(); break;
    case 'J':
    case 'j':
      dot(); dash(); dash(); dash(); break;
    case 'K':
    case 'k':
      dash(); dot(); dash(); break;
    case 'L':
    case 'l':
      dot(); dash(); dot(); dot(); break;
    case 'M':
    case 'm':
      dash(); dash(); break;
    case 'N':
    case 'n':
      dash(); dot(); break;
    case 'O':
    case 'o':
      dash(); dash(); dash(); break;
    case 'P':
    case 'p':
      dot(); dash(); dash(); dot(); break;
    case 'Q':
    case 'q':
      dash(); dash(); dot(); dash(); break;
    case 'R':
    case 'r':
      dot(); dash(); dot(); break;
    case 'S':
    case 's':
      dot(); dot(); dot(); break;
    case 'T':
    case 't':
      dash(); break;
    case 'U':
    case 'u':
      dot(); dot(); dash(); break;
    case 'V':
    case 'v':
      dot(); dot(); dot(); dash(); break;
    case 'W':
    case 'w':
      dot(); dash(); dash(); break;
    case 'X':
    case 'x':
      dash(); dot(); dot(); dash(); break;
    case 'Y':
    case 'y':
      dash(); dot(); dash(); dash(); break;
    case 'Z':
    case 'z':
      dash(); dash(); dot(); dot(); break;
    case 0:
    case '0':
      dash(); dash(); dash(); dash(); dash(); break;
    case 1:
    case '1':
      dot(); dash(); dash(); dash(); dash(); break;
    case 2:
    case '2':
      dot(); dot(); dash(); dash(); dash(); break;
    case 3:
    case '3':
      dot(); dot(); dot(); dash(); dash(); break;
    case 4:
    case '4':
      dot(); dot(); dot(); dot(); dash(); break;
    case 5:
    case '5':
      dot(); dot(); dot(); dot(); dot(); break;
    case 6:
    case '6':
      dash(); dot(); dot(); dot(); dot(); break;
    case 7:
    case '7':
      dash(); dash(); dot(); dot(); dot(); break;
    case 8:
    case '8':
      dash(); dash(); dash(); dot(); dot(); break;
    case 9:
    case '9':
      dash(); dash(); dash(); dash(); dot(); break;
    case ' ':
      delay_ms(1000); break;
    default:
      dash(); dot(); dot(); dash(); break;
  }
  delay_ms(1000);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -