68 lines
1.3 KiB
C++
68 lines
1.3 KiB
C++
#define SizeRegisterModules 20
|
|
#include "musics.h"
|
|
#include "QB.h"
|
|
#include "QBmusics.h"
|
|
|
|
int IDarg = 0;
|
|
String ParsedCommand[SizeRegisterModules];
|
|
|
|
int adding;
|
|
|
|
void ShowError(String errorMessage){
|
|
Serial.println("Error: \n "+errorMessage);
|
|
}
|
|
|
|
void ShowMessage(String type, String Message){
|
|
Serial.println("["+type+"] "+Message);
|
|
}
|
|
|
|
char getCharCommand(){
|
|
if (Serial.available() > 0) {
|
|
char cmdraw = Serial.read();
|
|
if (cmdraw > 0) return cmdraw;
|
|
}
|
|
return '?';
|
|
}
|
|
|
|
void mainL(String *args){
|
|
if(args[0] == "play") {
|
|
String prom = args[2];
|
|
int data = prom.toInt();
|
|
if(args[2] == "") {
|
|
Serial.println("Введите пин!");
|
|
return 1;
|
|
}
|
|
if(args[1] == "mario") {
|
|
mario(data,false);
|
|
}
|
|
if(args[1] == "Bells") {
|
|
bell(data,false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
ShowMessage("Note","Type ';' to indicate the end of command, and then press 'Enter'");
|
|
Serial.print("\n \n \n \n>");
|
|
}
|
|
|
|
void loop() {
|
|
char CharCommand = getCharCommand();
|
|
if (CharCommand != ';' && CharCommand != '?'){
|
|
Serial.print(CharCommand);
|
|
if (CharCommand == ' '){
|
|
IDarg++;
|
|
}else{
|
|
ParsedCommand[IDarg] += CharCommand;
|
|
}
|
|
}else if(CharCommand == ';'){
|
|
Serial.println(" ");
|
|
mainL(ParsedCommand);
|
|
IDarg = 0;
|
|
for (int i = 0;i<=20;i++) {ParsedCommand[i]="";}
|
|
Serial.print(">");
|
|
}
|
|
}
|