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.

83 lines
2.0KB

  1. // Copyright 2012 Olivier Gillet.
  2. //
  3. // Author: Olivier Gillet (olivier@mutable-instruments.net)
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. //
  16. // Settings written to eeprom
  17. #include "edges/settings.h"
  18. #include "edges/storage.h"
  19. namespace edges {
  20. /* static */
  21. SettingsData Settings::data_;
  22. /* static */
  23. int16_t Settings::previous_code_[kNumChannels];
  24. /* static */
  25. int16_t Settings::previous_pitch_[kNumChannels];
  26. /* extern */
  27. Settings settings;
  28. typedef SettingsData PROGMEM prog_SettingsData;
  29. const prog_SettingsData init_settings PROGMEM = {
  30. { { 0, false, false, 3, 0,
  31. { 512, 1536, 0, 0, 0, 0, 0 }, 1536, 15360, -7680
  32. },
  33. { 0, false, false, 3, 0,
  34. { 512, 896, 0, 0, 0, 0, 0 }, 1536, 15360, -7680
  35. },
  36. { 0, false, false, 4, 0,
  37. { 512, 896, 1536, 0, 0, 0, 0 }, 1536, 15360, -7680
  38. },
  39. { 0, false, false, 5, 0,
  40. { 512, 896, 1536, 3072, 0, 0, 0 }, 1536, 15360, -7680
  41. } },
  42. 0,
  43. 0
  44. };
  45. template<>
  46. struct StorageLayout<SettingsData> {
  47. static uint16_t eeprom_address() {
  48. return 0;
  49. }
  50. static const prog_char* init_data() {
  51. return (prog_char*)&init_settings;
  52. }
  53. };
  54. /* static */
  55. void Settings::Init(bool reset_to_factory_defaults) {
  56. if (reset_to_factory_defaults) {
  57. storage.ResetToFactoryDefaults(&data_);
  58. } else {
  59. storage.Load(&data_);
  60. }
  61. }
  62. /* static */
  63. void Settings::Save() {
  64. storage.Save(data_);
  65. }
  66. } // namespace edges