Advertisement
j0h

BigBuddy Talker Dialog 2 memory

j0h
Oct 9th, 2021 (edited)
1,195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.92 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #3% more efficient, and generates 5 times fewer lines of code!
  4. #Read dialog get the word on a line, then find the memory location and chip it is on
  5. #rec_column2 is the address in the chip for the word
  6. #cs=Chip Select, the value of rec_column3
  7. #wordlist is the library xlsx coverted via: for i  in *.xlsx; do  libreoffice --headless --convert-to csv "$i" ; done
  8. #then put in all lower case becuase I dont know how to compare values that only differ by case
  9. #command used: tr '[:upper:]' '[:lower:]' < input.csv > wordlist.csv
  10.  
  11. echo "#include <SPI.h>    // include the SPI communcation library
  12. // Connect pin#13 (SCLK) To S2 on AP23
  13. // Connect pin#11 (DATOUT) To S3 on AP23
  14. // Connect pin#13 (SCLK) To S2 on AP23
  15. // Connect pin#10 (CS) To S1 on AP23
  16. // DO from Ap23 optional S4 - Not used here
  17. #define cs 10          // These are the chip-select pins for SPI. They control chips 1-4
  18. #define cs2 9
  19. #define cs3 8
  20. #define cs4 7
  21. int hold = 0;       // Integer used when calling words
  22. int del=200;        // short 200ms delay
  23. int value1 = 0x98;  // play command - This value never changes
  24. int value2 = 0;  // voice address - when you place a hex value in this integer and call the readout() function, that specific word will play
  25. int value3 = 0xA8;  // COUT ramp up - This value never changes
  26. int value4 = 0xB8;   // COUT ramp down - This value never changes
  27. // ALL OF THE ABOVE CODE IS REQUIRED FOR THE OPERATION OF THE LBT
  28. "
  29. echo "int DTime=666;"
  30. echo "void readWord(int addr, int chip){
  31. digitalWrite(chip,LOW);          //Turn a chip on
  32. SPI.transfer(152);                //playcommand
  33. SPI.transfer(addr);              //Transfer the word
  34. digitalWrite(chip,HIGH);        //Turn the chip off
  35. delay(DTime);                       // Dealy between words
  36. }"
  37.  
  38. echo "
  39. void setup(){
  40.  SPI.begin();             // Initialize SPI
  41.  SPI.setClockDivider(SPI_CLOCK_DIV32); // low frequency SPI
  42.  pinMode(cs,OUTPUT);    // Chip select pins is an output
  43.  pinMode(cs2,OUTPUT);    // Chip select pins is an output
  44.  pinMode(cs3,OUTPUT);    // Chip select pins is an output
  45.  pinMode(cs4,OUTPUT);    // Chip select pins is an output
  46.  digitalWrite(cs,HIGH); // Set chip select to be HIGH (5v) by default.  The chip on the shield is selected when this line is brought low.
  47.  digitalWrite(cs2,HIGH); // Set chip select to be HIGH (5v) by default.  The chip on the shield is selected when this line is brought low.
  48.  digitalWrite(cs3,HIGH); // Set chip select to be HIGH (5v) by default.  The chip on the shield is selected when this line is brought low.
  49.  digitalWrite(cs4,HIGH); // Set chip select to be HIGH (5v) by default.  The chip on the shield is selected when this line is brought low.
  50.  SPI.setBitOrder(MSBFIRST);  // OTP requires MSB first
  51.  SPI.setDataMode(SPI_MODE0);  // Use MODE0, as all other modes to not work
  52.  value2 = 0x00; // Start at voice group 0
  53.  delay(1000);   // One second delay
  54.  // The following code sets up the output of each chip.  
  55.  digitalWrite(cs,LOW);
  56.  SPI.transfer(value3);
  57.  SPI.transfer(0x00);
  58.  digitalWrite(cs,HIGH);
  59.  delay(5);
  60.  digitalWrite(cs2,LOW);
  61.  SPI.transfer(value3);
  62.  SPI.transfer(0x00);
  63.  digitalWrite(cs2,HIGH);
  64.  delay(5);
  65.   digitalWrite(cs3,LOW);
  66.  SPI.transfer(value3);
  67.  SPI.transfer(0x00);
  68.  digitalWrite(cs3,HIGH);
  69.  delay(5);
  70.  digitalWrite(cs4,LOW);
  71.  SPI.transfer(value3);
  72.  SPI.transfer(0x00);
  73.  digitalWrite(cs4,HIGH);
  74. }
  75. "
  76. echo "void loop(){"
  77. input="dialog"
  78. while IFS= read -r line
  79. do
  80.  
  81. while IFS="," read -r rec_column1 rec_column2 rec_column3
  82. do
  83. if test "$line" = "$rec_column1"
  84.     then
  85.            echo "// " $line " , " $rec_column1 " :: " $rec_column2 ", " $rec_column3        
  86.      echo "readWord($rec_column2,  $rec_column3);"
  87.  
  88.     break
  89. fi
  90.  
  91. done < wordlist.csv
  92.  
  93. #Word Not Found
  94. if test "$line" != "$rec_column1"
  95. then
  96. echo "//" $line " Not Found"
  97.  
  98. fi
  99.  
  100. done < $input
  101.  
  102. echo "}"
  103.        
  104.   ###PINS###
  105.   #cs==10
  106.   #cs2==9
  107.   #cs3==8
  108.   #cs4==7
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement