forked from ewoudwijma/StarBase
-
Notifications
You must be signed in to change notification settings - Fork 3
Hub75 #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
netmindz
wants to merge
3
commits into
main
Choose a base branch
from
HUB75
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Hub75 #7
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| @title StarMod | ||
| @file UserModHub75.h | ||
| @date 20231016 | ||
| @repo https://github.com/ewowi/StarMod | ||
| @Authors https://github.com/ewowi/StarMod/commits/main | ||
| @Copyright (c) 2023 Github StarMod Commit Authors | ||
| @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 | ||
| */ | ||
|
|
||
| #include <MatrixHardware_ESP32_V0.h> | ||
| #include <SmartMatrix.h> | ||
|
|
||
| #define COLOR_DEPTH 24 // Choose the color depth used for storing pixels in the layers: 24 or 48 (24 is good for most sketches - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24) | ||
| const uint16_t kMatrixWidth = 32; // Set to the width of your display, must be a multiple of 8 | ||
| const uint16_t kMatrixHeight = 32; // Set to the height of your display | ||
| const uint8_t kRefreshDepth = 36; // Tradeoff of color quality vs refresh rate, max brightness, and RAM usage. 36 is typically good, drop down to 24 if you need to. On Teensy, multiples of 3, up to 48: 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48. On ESP32: 24, 36, 48 | ||
| const uint8_t kDmaBufferRows = 4; // known working: 2-4, use 2 to save RAM, more to keep from dropping frames and automatically lowering refresh rate. (This isn't used on ESP32, leave as default) | ||
| const uint8_t kPanelType = SM_PANELTYPE_HUB75_32ROW_MOD16SCAN; // Choose the configuration that matches your panels. See more details in MatrixCommonHub75.h and the docs: https://github.com/pixelmatix/SmartMatrix/wiki | ||
| const uint32_t kMatrixOptions = (SM_HUB75_OPTIONS_NONE); // see docs for options: https://github.com/pixelmatix/SmartMatrix/wiki | ||
| const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE); | ||
| const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE); | ||
| const uint8_t kIndexedLayerOptions = (SM_INDEXED_OPTIONS_NONE); | ||
|
|
||
| SMARTMATRIX_ALLOCATE_BUFFERS(smartMatrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions); | ||
|
|
||
| SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions); | ||
|
|
||
| class UserModHub75:public Module { | ||
|
|
||
| public: | ||
|
|
||
| UserModHub75() :Module("HUB75") { | ||
| USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name); | ||
|
|
||
| isEnabled = false; //default off | ||
|
|
||
| USER_PRINT_FUNCTION("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed"); | ||
| }; | ||
|
|
||
| //setup filesystem | ||
| void setup() { | ||
| Module::setup(); | ||
| USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name); | ||
|
|
||
| parentVar = ui->initModule(parentVar, name); | ||
|
|
||
| smartMatrix.addLayer(&backgroundLayer); | ||
| smartMatrix.setBrightness(125); | ||
| smartMatrix.begin(); | ||
|
|
||
| buffer = backgroundLayer.backBuffer(); | ||
|
|
||
| USER_PRINT_FUNCTION("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed"); | ||
| } | ||
|
|
||
| void loop() { | ||
| // Module::loop(); | ||
|
|
||
| if(!SysModModules::isConnected) return; | ||
|
|
||
| if(!lds->newFrame) return; | ||
|
|
||
| int bri = mdl->getValue("bri"); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mdl->getValue is too expensive to call in loop() recently added variables by reference, so added bri as a referenced variable here: Check e3b85de so fix->bri can be used here as well |
||
|
|
||
| for (size_t i = 0; i < ledsV.nrOfLedsP; i++) { | ||
| CRGB pixel = ledsP[i]; | ||
| buffer[i] = rgb24(scale8(pixel.r, bri), scale8(pixel.g, bri), scale8(pixel.b, bri)); | ||
| } | ||
|
|
||
| backgroundLayer.swapBuffers(true); | ||
| } | ||
|
|
||
| private: | ||
| rgb24* buffer; | ||
|
|
||
| }; | ||
|
|
||
| static UserModHub75 *hub75Mod; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default builds disabled / commented ?