MicroDexed is a compatible 6-operator-FM-synth based on the Teensy(-3.6/-4.0) Microcontroller. https://www.parasitstudio.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.4KB

  1. /*
  2. MicroDexed
  3. MicroDexed is a port of the Dexed sound engine
  4. (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield.
  5. Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android
  6. (c)2018 H. Wirtz <wirtz@parasitstudio.de>
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 3 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software Foundation,
  17. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include <LiquidCrystal_I2C.h> // https://www.arduinolibraries.info/libraries/liquid-crystal-i2-c
  20. #ifndef LIQUIDCRYSTALPLUS_I2C_H_INCLUDED
  21. #define LIQUIDCRYSTALPLUS_I2C_H_INCLUDED
  22. #define STRING_BUF_SIZE 21
  23. class LiquidCrystalPlus_I2C : public LiquidCrystal_I2C
  24. {
  25. public:
  26. using LiquidCrystal_I2C::LiquidCrystal_I2C;
  27. void show(uint8_t y, uint8_t x, uint8_t fs, const char *str)
  28. {
  29. _show(y, x, fs, str, false, false);
  30. }
  31. void show(uint8_t y, uint8_t x, uint8_t fs, long num)
  32. {
  33. char _buf10[STRING_BUF_SIZE];
  34. _show(y, x, fs, itoa(num, _buf10, 10), true, true);
  35. }
  36. private:
  37. void _show(uint8_t pos_y, uint8_t pos_x, uint8_t field_size, const char *str, bool justify_right, bool fill_zero)
  38. {
  39. {
  40. char tmp[STRING_BUF_SIZE];
  41. char *s = tmp;
  42. uint8_t l = strlen(str);
  43. memset(tmp, 0, sizeof(tmp));
  44. if (fill_zero == true)
  45. memset(tmp, '0', field_size);
  46. else
  47. memset(tmp, 0x20, field_size - 1); // blank
  48. if (l > field_size)
  49. l = field_size;
  50. if (justify_right == true)
  51. s += field_size - l;
  52. strncpy(s, str, l);
  53. setCursor(pos_x, pos_y);
  54. print(tmp);
  55. #ifdef DEBUG
  56. Serial.print(pos_y, DEC);
  57. Serial.print(F("/"));
  58. Serial.print(pos_x, DEC);
  59. Serial.print(F(": ["));
  60. Serial.print(tmp);
  61. Serial.println(F("]"));
  62. #endif
  63. }
  64. }
  65. };
  66. #endif