Indexed layer colour depth increase and layer disabling option #163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
This PR is to add 2-bit, 4-bit and 8-bit colour indexing ability to the indexed layer. It's fairly straightforward to use, and not really different to the existing functionality other than the constructors have an option to choose the bit depth for the colour index and that the index parameter in the functions chooses the colour index (as opposed to just setting/resetting a bit). It is backward compatible with existing code that uses the indexed layer, so it should not cause any problems there. The memory footprint should pretty much be the same as before (increasing with the number of bits for the colour index, of course). I've defined a macro
SMARTMATRIX_ALLOCATE_INDEXED_LAYER_EXTENDED
that will take an additional parameter to set the colour index bit depth, keeping the existing macro for backwards compatibility. The colour index of 0 will always be transparent, and a colour cannot be allocated to it, regardless of the number of bits used for the colour index.In terms of speed, I've tried to optimise it somewhat and there may be a way to improve on that, but it works pretty well. However, for my application, I needed the screen updates to be faster, particularly as some of the applications don't need to use all the defined layers at the same time. Therefore, I added two functions to SM_Layer:
enable
andisEnabled
.enable
will enable/disable a layer from refreshing onto the screen when not needed by the user, andisEnabled
gives the status of the layer. This can bring a nice speed increase in processing, should it be required.Finally, I realised that I made changes to the code with the ability to disable the version messages coming out from the hardware header files. Defining
SM_INTERNAL
disables these messages.I hope you find that useful!