summaryrefslogtreecommitdiff
path: root/apps/plugins/bitmaps
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/bitmaps')
0 files changed, 0 insertions, 0 deletions
'n73' href='#n73'>73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
#include <led.h>
#include <iostream>
#include <string>
#include <map>
#include <ctime>
#include <cctype>
#include <unistd.h>
#include <cstring>
using namespace std;
void dot()
{
  cout << "." << flush;
  setLight(true);
  usleep(250000);
  setLight(false);
}
void dash()
{
  cout << "-" << flush;
  setLight(true);
  usleep(750000);
  setLight(false);
}
static map<string, string> table;
void transmit(const string& str)
{
  cout << "Transmitting message in Morse code via ACT LED..." << endl;
  for(unsigned long long i=0;i<str.length();++i)
    {
      char ch=str[i];
      string tmp;
      tmp=toupper(ch);
      string morse=table[tmp];
      if(morse!="")
	cout << (char)toupper(ch) << ": " << flush;
      for(unsigned int j=0;j<morse.length();++j)
	{
	  char morseCh=morse[j];
	  if(morseCh=='.')
	    dot();
	  else if(morseCh=='-')
	    dash(); 
	  usleep(200000);
	}
      if(morse!="")
	cout << " " << flush;
      usleep(250000); // between chars
      if(isspace(ch))
	{
	  cout << " " << flush;
	  usleep(500000); // extra for spaces
	}
    }
}

void init_morse()
{
  table["A"]=".-";
  table["B"]="-...";
  table["C"]="-.-.";
  table["D"]="-..";
  table["E"]=".";
  table["F"]="..-.";
  table["G"]="--.";
  table["H"]="....";
  table["I"]="..";