-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20482f5
commit f73c1ec
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,21 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <cstdio> | ||
|
||
namespace DMDUtil | ||
{ | ||
|
||
class ConsoleDMD | ||
{ | ||
public: | ||
ConsoleDMD(FILE* f); | ||
~ConsoleDMD(); | ||
|
||
void Render(uint8_t* buffer, uint16_t width, uint16_t height, uint8_t bitDepth); | ||
|
||
private: | ||
FILE* out; | ||
}; | ||
|
||
} // namespace DMDUtil |
This file contains 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 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,45 @@ | ||
#include "DMDUtil/ConsoleDMD.h" | ||
|
||
#include <stdio.h> | ||
|
||
namespace DMDUtil | ||
{ | ||
|
||
ConsoleDMD::ConsoleDMD(FILE* f) { out = f; } | ||
|
||
ConsoleDMD::~ConsoleDMD() {} | ||
|
||
void ConsoleDMD::Render(uint8_t* buffer, uint16_t width, uint16_t height, uint8_t bitDepth) | ||
{ | ||
for (uint16_t y = 0; y < height; y++) | ||
{ | ||
for (uint16_t x = 0; x < width; x++) | ||
{ | ||
uint8_t value = buffer[y * width + x]; | ||
if (bitDepth > 2) | ||
{ | ||
fprintf(out, "%2x", value); | ||
} | ||
else | ||
{ | ||
switch (value) | ||
{ | ||
case 0: | ||
fprintf(out, "\033[0;40m⚫\033[0m"); | ||
break; | ||
case 1: | ||
fprintf(out, "\033[0;40m🟤\033[0m"); | ||
break; | ||
case 2: | ||
fprintf(out, "\033[0;40m🟠\033[0m"); | ||
break; | ||
case 3: | ||
fprintf(out, "\033[0;40m🟡\033[0m"); | ||
break; | ||
} | ||
} | ||
} | ||
fprintf(out, "\n"); | ||
} | ||
} | ||
} // namespace DMDUtil |
This file contains 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 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