dtmf_dolphin_tone.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include "dtmf_dolphin_tone.h"
  2. const char* dtmf_dolphin_get_tone_name(uint8_t row, uint8_t col, DTMFDolphinToneSection block) {
  3. if (block == DTMF_DOLPHIN_TONE_BLOCK_DIALER) {
  4. for (int i = 0; i < DTMF_DOLPHIN_DIALER_TONE_COUNT; i++) {
  5. if (dtmf_dolphin_dialer_tone[i].pos.row == row && dtmf_dolphin_dialer_tone[i].pos.col == col) {
  6. return dtmf_dolphin_dialer_tone[i].name;
  7. }
  8. }
  9. } else if (block == DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX) {
  10. // if (index < DTMF_DOLPHIN_BLUEBOX_TONE_COUNT) {
  11. // return dtmf_dolphin_bluebox_tone[index].name;
  12. // }
  13. }
  14. return "N";
  15. }
  16. uint8_t dtmf_dolphin_get_tone_span(uint8_t row, uint8_t col, DTMFDolphinToneSection block) {
  17. if (block == DTMF_DOLPHIN_TONE_BLOCK_DIALER) {
  18. for (int i = 0; i < DTMF_DOLPHIN_DIALER_TONE_COUNT; i++) {
  19. if (dtmf_dolphin_dialer_tone[i].pos.row == row && dtmf_dolphin_dialer_tone[i].pos.col == col) {
  20. return dtmf_dolphin_dialer_tone[i].pos.span;
  21. }
  22. }
  23. } else if (block == DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX) {
  24. // if (index < DTMF_DOLPHIN_BLUEBOX_TONE_COUNT) {
  25. // return dtmf_dolphin_bluebox_tone[index].name;
  26. // }
  27. }
  28. return 1; // Default to 1
  29. }
  30. void dtmf_dolphin_get_tone_frequencies(float *freq, uint8_t row, uint8_t col, DTMFDolphinToneSection block) {
  31. freq[0] = 0;
  32. freq[1] = 0;
  33. if (block == DTMF_DOLPHIN_TONE_BLOCK_DIALER) {
  34. for (int i = 0; i < DTMF_DOLPHIN_DIALER_TONE_COUNT; i++) {
  35. if (dtmf_dolphin_dialer_tone[i].pos.row == row && dtmf_dolphin_dialer_tone[i].pos.col == col) {
  36. freq[0] = dtmf_dolphin_dialer_tone[i].frequency_1;
  37. freq[1] = dtmf_dolphin_dialer_tone[i].frequency_2;
  38. }
  39. }
  40. } else if (block == DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX) {
  41. // if (index < DTMF_DOLPHIN_BLUEBOX_TONE_COUNT) {
  42. // return dtmf_dolphin_bluebox_tone[index].name;
  43. // }
  44. }
  45. }
  46. void dtmf_dolphin_tone_get_max_pos(uint8_t *max_rows, uint8_t *max_cols, uint8_t *max_span, DTMFDolphinToneSection block) {
  47. max_rows[0] = 0;
  48. max_cols[0] = 0;
  49. max_span[0] = 0;
  50. uint8_t span[8] = { 0 };
  51. if (block == DTMF_DOLPHIN_TONE_BLOCK_DIALER) {
  52. for (int i = 0; i < DTMF_DOLPHIN_DIALER_TONE_COUNT; i++) {
  53. if (dtmf_dolphin_dialer_tone[i].pos.row > max_rows[0])
  54. max_rows[0] = dtmf_dolphin_dialer_tone[i].pos.row;
  55. if (dtmf_dolphin_dialer_tone[i].pos.col > max_cols[0])
  56. max_cols[0] = dtmf_dolphin_dialer_tone[i].pos.col;
  57. span[dtmf_dolphin_dialer_tone[i].pos.row] += dtmf_dolphin_dialer_tone[i].pos.span;
  58. }
  59. max_rows[0]++;
  60. max_cols[0]++;
  61. for (int i = 0; i < max_rows[0]; i++) {
  62. if (span[i] > max_span[0])
  63. max_span[0] = span[i];
  64. }
  65. } else if (block == DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX) {
  66. // if (index < DTMF_DOLPHIN_BLUEBOX_TONE_COUNT) {
  67. // for (int i; i < DTMF_DOLPHIN_BLUEBOX_TONE_COUNT; i++) {
  68. // if (dtmf_dolphin_bluebox_tone[i].pos.row > max_rows)
  69. // max_rows = dtmf_dolphin_bluebox_tone[i].pos.row;
  70. // if (dtmf_dolphin_bluebox_tone[i].pos.col > max_cols)
  71. // max_cols = dtmf_dolphin_bluebox_tone[i].pos.col;
  72. // }
  73. }
  74. }
  75. // void dtmf_dolphin_bluebox_generate(uint8_t index, uint8_t *buffer) {
  76. // // TODO: Generate the waveform
  77. // }