Makefile 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. # Creating RGB matrix library
  2. # When you link this library with your binary, you need to add -lrt -lm -lpthread
  3. # So
  4. # -lrgbmatrix
  5. ##
  6. OBJECTS=gpio.o led-matrix.o options-initialize.o framebuffer.o \
  7. thread.o bdf-font.o graphics.o led-matrix-c.o hardware-mapping.o \
  8. pixel-mapper.o multiplex-mappers.o \
  9. content-streamer.o
  10. TARGET=librgbmatrix
  11. ###
  12. # After you change any of the following DEFINES, make sure to 'make' again.
  13. #
  14. # ########### NOTE ###########
  15. # all of these options can now can be set programmatically and
  16. # via command line flags as well. No real need to change them in the Makefile.
  17. # (So be prepared for these to be removed at some point)
  18. ###
  19. # There are several different pinouts for various breakout boards that uses
  20. # this library. If you are using the described pinout in the toplevel README.md
  21. # or the standard active-3 breakout board, then 'regular' is the one you'd like
  22. # to use.
  23. #
  24. # Adafruit also made a breakout board, if you want to use that, choose
  25. # 'adafruit-hat'
  26. #
  27. # These are the choices
  28. # regular # Following this project wiring and using these PCBs
  29. # adafruit-hat # If you have a RGB matrix HAT from Adafruit
  30. # adafruit-hat-pwm # If you have an Adafruit HAT with PWM hardware mod.
  31. # regular-pi1 # If you have an old Pi1 and regular didn't work.
  32. # classic # (deprecated) Classic Pi1/2/. Not used anymore.
  33. # classic-pi1 # (deprecated) Classic pinout on Rasperry Pi 1
  34. HARDWARE_DESC?=regular
  35. # If you see that your display is inverse, you might have a matrix variant
  36. # has uses inverse logic for the RGB bits. In that case: uncomment this.
  37. # Flag: --led-inverse
  38. #DEFINES+=-DINVERSE_RGB_DISPLAY_COLORS
  39. # For curiosity reasons and while tweaking values for LSB_PWM_NANOSECONDS,
  40. # uncomment to see refresh rate in terminal.
  41. # Flag: --led-show-refresh
  42. #DEFINES+=-DSHOW_REFRESH_RATE
  43. # For low refresh rates below 100Hz (e.g. a lot of panels), the eye will notice
  44. # some flicker. With this option enabled, the refreshed lines are interleaved,
  45. # so it is less noticeable. But looks less pleasant with fast eye movements.
  46. # Flag: --led-scan-mode=1
  47. #DEFINES+=-DRGB_SCAN_INTERLACED=1
  48. # The signal can be too fast for some LED panels, in particular with newer
  49. # (faster) Raspberry Pi 2s - in that case, the LED matrix only shows garbage.
  50. # This allows to slow down the GPIO for these cases.
  51. #
  52. # Set to 1 for RPi2 or RPi3 (default below), because they are typically
  53. # faster than the panels can digest.
  54. #
  55. # Set to 0 (or comment out) for RPi1, that are slow enough.
  56. #
  57. # Sometimes, you even have to give RGB_SLOWDOWN_GPIO=2 or even 3 for
  58. # particularly slow panels or bad signal cable situations. If that happens, you
  59. # typically should double check cables and add TTL level converter if you
  60. # haven't.
  61. # Flag: --led-slowdown-gpio
  62. #DEFINES+=-DRGB_SLOWDOWN_GPIO=1
  63. # This allows to change the base time-unit for the on-time in the lowest
  64. # significant bit in nanoseconds.
  65. # Higher numbers provide better quality (more accurate color, less ghosting),
  66. # but have a negative impact on the frame rate.
  67. #
  68. # For the same frame-rate, displays with higher multiplexing (e.g. 1:16 or 1:32)
  69. # require lower values.
  70. #
  71. # Good values for full-color display (PWM=11) are somewhere between 100 and 300.
  72. #
  73. # If you you use reduced bit color (e.g. PWM=1 for 8 colors like for text),
  74. # then higher values might be good to minimize ghosting (and you can afford
  75. # that, because lower PWM values result in higher frame-rates).
  76. #
  77. # How to decide ? Just leave the default if things are fine. If you see
  78. # ghosting in high-contrast applications (e.g. text), increase the value.
  79. # If you want to tweak, watch the framerate (-DSHOW_FRAME_RATE) while playing
  80. # with this number and the PWM values.
  81. # Flag: --led-pwm-lsb-nanoseconds
  82. #DEFINES+=-DLSB_PWM_NANOSECONDS=130
  83. # This is to debug problems with the hardware pulse generation. The PWM hardware
  84. # module is also used by Raspberry Pi sound system, so there might be
  85. # interference. Note, you typically don't want the hardware pulses disabled, as
  86. # the image will have visible brightness glitches; but for debugging, this is
  87. # a good choice.
  88. # Flag: --led-no-hardware-pulses
  89. #DEFINES+=-DDISABLE_HARDWARE_PULSES
  90. # This allows to fix the refresh rate to a particular refresh time in
  91. # microseconds.
  92. #
  93. # This can be used to mitigate some situations in which you have a rare
  94. # faint flicker, which can happen due to hardware events (network access)
  95. # or other situations such as other IO or heavy memory access by other
  96. # processes (all of which seem to break the isolation we request from the
  97. # kernel. You did set isolcpus=3 right ?)
  98. # You trade a slightly slower refresh rate and display brightness for less
  99. # visible flicker situations.
  100. #
  101. # For this to calibrate, run your program for a while with --led-show-refresh
  102. # and watch the line that shows the refresh time and the maximum microseconds
  103. # for a frame observed. The maximum number is updated whenever the frame
  104. # refresh take a little bit longer. So wait a while until that value doesn't
  105. # change anymore (at least a minute, so that you catch tasks that happen once
  106. # a minute). Some value might read e.g.
  107. # 204.6Hz max: 5133usec
  108. # Now take this maximum value you see there (here: 5133) and put in
  109. # this define (don't forget to remove the # in front).
  110. #
  111. # The refresh rate will now be adapted to always have this amount of time
  112. # between frames, so faster refreshes will be slowed down, but the occasional
  113. # delayed frame will fit into the time-window as well, thus reducing visible
  114. # brightness fluctuations.
  115. #
  116. # You can play with value a little and reduce until you find a good balance
  117. # between refresh rate (which is reduce the higher this value is) and
  118. # flicker suppression (which is better with higher values).
  119. # Flag: --led-limit-refresh
  120. #DEFINES+=-DFIXED_FRAME_MICROSECONDS=5000
  121. # Enable wide 64 bit GPIO offered with the compute module.
  122. # This will use more memory to internally represent the frame buffer, so
  123. # caches can't be utilized as much.
  124. # So only switch this on if you really use the compute module and use more
  125. # than 3 parallel chains.
  126. # (this is untested right now, waiting for hardware to arrive for testing)
  127. #DEFINES+=-DENABLE_WIDE_GPIO_COMPUTE_MODULE
  128. # ---- Pinout options for hardware variants; usually no change needed here ----
  129. # Uncomment if you want to use the Adafruit HAT with stable PWM timings.
  130. # The newer version of this library allows for much more stable (less flicker)
  131. # output, but it does not work with the Adafruit HAT unless you do a
  132. # simple hardware hack on them:
  133. # connect GPIO 4 (old OE) with 18 (the new OE); there are
  134. # convenient solder holes labeled 4 and 18 on the Adafruit HAT, pretty
  135. # close together.
  136. # Then you can set the flag --led-gpio-mapping=adafruit-hat-pwm
  137. # .. or uncomment the following line.
  138. #HARDWARE_DESC=adafruit-hat-pwm
  139. # Typically, a Hub75 panel is split in two half displays, so that a 1:16
  140. # multiplexing actually multiplexes over two half displays and gives 32 lines.
  141. # There are some other displays out there that you might experiment with
  142. # that are internally wired to only have one sub-panel. In that case you might
  143. # want to try this define to get a more reasonable canvas mapping.
  144. # This option is typically _not_ needed, only use when you attempt to connect
  145. # some oddball old (typically one-colored) display, such as Hub12.
  146. #DEFINES+=-DONLY_SINGLE_SUB_PANEL
  147. # If someone gives additional values on the make commandline e.g.
  148. # make USER_DEFINES="-DSHOW_REFRESH_RATE"
  149. DEFINES+=$(USER_DEFINES)
  150. DEFINES+=-DDEFAULT_HARDWARE='"$(HARDWARE_DESC)"'
  151. INCDIR=../include
  152. CFLAGS=-W -Wall -Wextra -Wno-unused-parameter -O3 -g -fPIC $(DEFINES)
  153. CXXFLAGS=$(CFLAGS) -fno-exceptions -std=c++11
  154. all : $(TARGET).a $(TARGET).so.1
  155. $(TARGET).a : $(OBJECTS)
  156. $(AR) rcs $@ $^
  157. $(TARGET).so.1 : $(OBJECTS)
  158. $(CXX) -shared -Wl,-soname,$@ -o $@ $^ -lpthread -lrt -lm -lpthread
  159. led-matrix.o: led-matrix.cc $(INCDIR)/led-matrix.h
  160. thread.o : thread.cc $(INCDIR)/thread.h
  161. framebuffer.o: framebuffer.cc framebuffer-internal.h
  162. graphics.o: graphics.cc utf8-internal.h
  163. %.o : %.cc compiler-flags
  164. $(CXX) -I$(INCDIR) $(CXXFLAGS) -c -o $@ $<
  165. %.o : %.c compiler-flags
  166. $(CC) -I$(INCDIR) $(CFLAGS) -c -o $@ $<
  167. clean:
  168. rm -f $(OBJECTS) $(TARGET).a $(TARGET).so.1
  169. compiler-flags: FORCE
  170. @echo '$(CXX) $(CXXFLAGS)' | cmp -s - $@ || echo '$(CXX) $(CXXFLAGS)' > $@
  171. .PHONY: FORCE