deprecated-transformer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
  2. // Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
  3. // Copyright (C) 2015 Christoph Friedrich <christoph.friedrich@vonaffenfels.de>
  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 version 2.
  8. //
  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. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://gnu.org/licenses/gpl-2.0.txt>
  16. /*
  17. * Deprecated.
  18. *
  19. * Use PixelMapper instead. See pixel-mapper.h
  20. */
  21. #ifndef RPI_TRANSFORMER_H
  22. #define RPI_TRANSFORMER_H
  23. #ifndef REMOVE_DEPRECATED_TRANSFORMERS
  24. #include <vector>
  25. #include <cstddef>
  26. #include "canvas.h"
  27. namespace rgb_matrix {
  28. // Transformer for RotateCanvas
  29. class RotateTransformer : public CanvasTransformer {
  30. public:
  31. RotateTransformer(int angle = 0);
  32. virtual ~RotateTransformer();
  33. void SetAngle(int angle);
  34. inline int angle() { return angle_; }
  35. virtual Canvas *Transform(Canvas *output);
  36. private:
  37. // Transformer canvas to rotate the input canvas in 90° steps
  38. class TransformCanvas;
  39. int angle_;
  40. TransformCanvas *const canvas_;
  41. };
  42. // Transformer for linked transformer objects
  43. // First transformer added will be considered last
  44. // (so it would the transformer that gets the original Canvas object)
  45. class LinkedTransformer : public CanvasTransformer {
  46. public:
  47. typedef std::vector<CanvasTransformer*> List;
  48. LinkedTransformer() {}
  49. LinkedTransformer(List transformer_list) : list_(transformer_list) {}
  50. // The ownership of the given transformers is _not_ taken over unless
  51. // you explicitly call DeleteTransformers().
  52. void AddTransformer(CanvasTransformer *transformer);
  53. void AddTransformer(List transformer_list);
  54. void SetTransformer(List transformer_list);
  55. // Delete transformers that have been added or set.
  56. void DeleteTransformers();
  57. // -- CanvasTransformer interface
  58. virtual Canvas *Transform(Canvas *output);
  59. private:
  60. List list_;
  61. };
  62. // If we take a long chain of panels and arrange them in a U-shape, so
  63. // that after half the panels we bend around and continue below. This way
  64. // we have a panel that has double the height but only uses one chain.
  65. // A single chain display with four 32x32 panels can then be arranged in this
  66. // 64x64 display:
  67. // [<][<][<][<] }- Raspbery Pi connector
  68. //
  69. // can be arranged in this U-shape
  70. // [<][<] }----- Raspberry Pi connector
  71. // [>][>]
  72. //
  73. // This works for more than one chain as well. Here an arrangement with
  74. // two chains with 8 panels each
  75. // [<][<][<][<] }-- Pi connector #1
  76. // [>][>][>][>]
  77. // [<][<][<][<] }--- Pi connector #2
  78. // [>][>][>][>]
  79. class UArrangementTransformer : public CanvasTransformer {
  80. public:
  81. UArrangementTransformer(int parallel = 1);
  82. ~UArrangementTransformer();
  83. virtual Canvas *Transform(Canvas *output);
  84. private:
  85. class TransformCanvas;
  86. TransformCanvas *const canvas_;
  87. };
  88. // Something used before, but it had a confusing 180 degree turn and was not
  89. // ready for multiple parallel chains. So consider using the
  90. // U-ArrangementTransformer instead.
  91. class LargeSquare64x64Transformer : public CanvasTransformer {
  92. public:
  93. LargeSquare64x64Transformer();
  94. virtual Canvas *Transform(Canvas *output);
  95. private:
  96. // This old transformer was a little off and rotated the whole result in
  97. // the end. simulated that here.
  98. UArrangementTransformer arrange_;
  99. RotateTransformer rotated_;
  100. } __attribute__((deprecated));
  101. } // namespace rgb_matrix
  102. #endif // REMOVE_DEPRECATED_TRANSFORMERS
  103. #endif // RPI_TRANSFORMER_H