SKOG
Published

Codec for P.O.T.S

Stylizing an approach from the past so we are efficient in the future. P.O.T.S. can have a codec in every language.

IntermediateWork in progress451
Codec for P.O.T.S

Things used in this project

Hardware components

Espruino Pico
×1

Software apps and online services

Espruino - IDE

Hand tools and fabrication machines

Makeblock RJ-45 connector

Story

Read more

Code

Codec for a P.O.T.S. line

JavaScript
It starts the concept of a codec. Hopefully at completion we arrive at the concept of stacking
/*
#START HELP

#Programm

     Program Name: Codex (P.O.T.S.).js
     Program Code: Java Script
     Company:      Integrated Control Systems
     Programmer:   Ralph Clark

#Design Control (future)
      
     A. The module % 3 parts  -  
          classifies a spreadsheet w/ hardware && expansionary build
     B. phonebook, autodial, database information with call request
     C. keypad, active call features, isolated dialing options
     D. Codec software integration, technical calling options, hardware
        parameters

#Debugg Information 

     1 - Primarily it is to create the secondary sheet composition.
     2 - the codec is really better placed on another script page.
     3 - saving the device [Codec} function for universal commands.
     4 - The input number 'n' on device function {changes} value to keep
         integrity.

#END HELP
*/

var tone = [[[0],[1]],["0","1","2","3","4","5","6","7","8","9","*","#"]];
var hz =   [  1209, 1336, 1477, 1633, 697, 770, 852, 941] ;
var n = "", kp = "", kp2 = ""; //i = 0;



/* dial functions */
function Dial (n) {
    i = n.length;
    for (var i in n){  
      Keypad(n.charAt(i),n);
      }
     
}

function Keypad(kp,n) {
  t = 0;
//switch for KP
switch (kp) {
   case "0":
    tone[0][0] = hz[4];
    tone[1][0] = hz[6];
    break;
   case "1":
    tone[0][1] = hz[1];
    tone[1][1] = hz[5];
    break;
   case "2":
    tone[0][2] = hz[1];
    tone[1][2] = hz[6];
    break;
   case "3":
    tone[0][3] = hz[1];
    tone[1][3] = hz[7];
    break;
   case "4":  
    tone[0][4] = hz[2];
    tone[1][4] = hz[5];
    break;
   case "5": 
    tone[0][5] = hz[2];
    tone[1][5] = hz[6];
    break;
   case "6":
    tone[0][6] = hz[2];
    tone[1][6] = hz[7];
    break;
   case "7": 
    tone[0][7] = hz[3];
    tone[1][7] = hz[5];
    break;
   case "8":
    tone[0][8] = hz[3];
    tone[1][8] = hz[6];
    break;
   case "9":
    tone[0][9] = hz[3];
    tone[1][9] = hz[7];
    break;
   case "*":
    tone[0][10] = hz[4];
    tone[1][10] = hz[5];
    break;
   case "#": 
    tone[0][11] = hz[4];
    tone[1][11] = hz[7];
    break;

   default: 
   
  }
  
  console.log("    ֍dialing (" + kp + ")");
  
  Codec(kp,n);

}

/* DTMF structure */
function Codec (kp,n) {

    kp2 += kp;
 
    if (kp2.length === n.length && i === kp2.length - 1) {
        i = 0;
        setInterval( function (){ 
          var t = kp2.charAt(i);
          if (kp2.charAt(i) === "*") t = 10;if (kp2.charAt(i) === "#") t = 11;
          analogWrite(A8,0.5,{freq:hz[tone[0][t]]});
          analogWrite(B7,0.5,{freq:hz[tone[1][t]]});
          console.log("dialtone " + tone[0][t] + " " + tone[1][t] + " ." + t);
          setTimeout(function(){
            analogWrite(A8,0,{freq:hz[tone[0][t]]});
            analogWrite(B7,0,{freq:hz[tone[1][t]]});
            i++;if ( i === kp2.length) { clearInterval();kp2 = "";}}, 400);
        }
          ,600 ); 
      }
}

Credits

SKOG

SKOG

1 project • 0 followers

Comments