My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

dl_cache.h 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**************
  2. * dl_cache.h *
  3. **************/
  4. /****************************************************************************
  5. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  6. * *
  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. * *
  12. * This program is distributed in the hope that it will be useful, *
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15. * GNU General Public License for more details. *
  16. * *
  17. * To view a copy of the GNU General Public License, go to the following *
  18. * location: <https://www.gnu.org/licenses/>. *
  19. ****************************************************************************/
  20. #pragma once
  21. /******************* DISPLAY LIST CACHE MANAGEMENT ************************/
  22. /* The Display List Cache mechanism stores the display list corresponding
  23. * to a menu into RAM_G so that on subsequent calls drawing the menu does
  24. * not require as much SPI traffic. Dynamic content, such as indicators,
  25. * should not be cached.
  26. *
  27. * The DLCache can be used like so:
  28. *
  29. * void some_function() {
  30. * DLCache dlcache(UNIQUE_ID);
  31. *
  32. * if (dlcache.hasData()) {
  33. * dlcache.append();
  34. * } else {
  35. * // Add stuff to the DL
  36. * dlcache.store();
  37. * }
  38. */
  39. class DLCache {
  40. private:
  41. typedef FTDI::ftdi_registers REG;
  42. typedef FTDI::ftdi_memory_map MAP;
  43. uint8_t dl_slot_indx;
  44. uint32_t dl_slot_addr;
  45. uint16_t dl_slot_size;
  46. uint16_t dl_slot_used;
  47. void load_slot() {load_slot(dl_slot_indx, dl_slot_addr, dl_slot_size, dl_slot_used);}
  48. void save_slot() {save_slot(dl_slot_indx, dl_slot_addr, dl_slot_size, dl_slot_used);}
  49. static void load_slot(uint8_t indx, uint32_t &addr, uint16_t &size, uint16_t &used);
  50. static void save_slot(uint8_t indx, uint32_t addr, uint16_t size, uint16_t used);
  51. bool wait_until_idle();
  52. public:
  53. static void init();
  54. DLCache(uint8_t slot) {
  55. dl_slot_indx = slot;
  56. load_slot();
  57. }
  58. bool has_data();
  59. bool store(uint32_t min_bytes = 0);
  60. void append();
  61. };
  62. #define DL_CACHE_SLOTS 250