working print to the terminal
This commit is contained in:
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
#define TARGET_TX_PIN USBTX
|
#define TARGET_TX_PIN USBTX
|
||||||
#define TARGET_RX_PIN USBRX
|
#define TARGET_RX_PIN USBRX
|
||||||
#define BAUD_RATE 115200
|
#define BAUD_RATE 1843200
|
||||||
|
// #define BAUD_RATE 460800
|
||||||
|
// #define BAUD_RATE 921600
|
||||||
|
|
||||||
static BufferedSerial serial_port(TARGET_TX_PIN, TARGET_RX_PIN, BAUD_RATE);
|
static BufferedSerial serial_port(TARGET_TX_PIN, TARGET_RX_PIN, BAUD_RATE);
|
||||||
|
|
||||||
@@ -18,22 +20,48 @@ DigitalOut led(LED1);
|
|||||||
#define BUFFER_SIZE 64
|
#define BUFFER_SIZE 64
|
||||||
static char rx_buffer[BUFFER_SIZE];
|
static char rx_buffer[BUFFER_SIZE];
|
||||||
|
|
||||||
// Draw shifting mask with optional centered text
|
// Draw a moving “sky + ground” background with optional message
|
||||||
void draw_mask(uint32_t mask, int shift, const char *text = nullptr)
|
void draw_mask(uint32_t mask, int shift, const char *text = nullptr)
|
||||||
{
|
{
|
||||||
printf("\033[2J\033[H"); // clear + home
|
const int width = 80; // terminal columns
|
||||||
|
const int height = 24; // terminal rows
|
||||||
|
const int horizon = 16; // sky ends here, ground below
|
||||||
|
|
||||||
for (int byte = 3; byte >= 0; byte--) {
|
printf("\033[2J\033[H"); // clear + home
|
||||||
uint8_t b = ((mask >> (byte * 8)) & 0xFF);
|
|
||||||
// Circular shift for movement illusion
|
// draw sky layer (moving clouds)
|
||||||
uint8_t rotated = (b << shift) | (b >> (8 - shift));
|
for (int y = 0; y < horizon; y++) {
|
||||||
for (int i = 7; i >= 0; i--) {
|
for (int x = 0; x < width; x++) {
|
||||||
printf("%c", (rotated & (1 << i)) ? '#' : '.');
|
// Parallax: slower movement at top
|
||||||
|
int move = (shift / 2 + y) % width;
|
||||||
|
char c = ((x + move) % 11 == 0) ? '☁' : ' ';
|
||||||
|
printf("%c", c);
|
||||||
}
|
}
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message under the mask
|
// draw horizon line
|
||||||
|
for (int i = 0; i < width; i++) printf("-");
|
||||||
|
printf("\r\n");
|
||||||
|
|
||||||
|
// draw ground (grass / terrain)
|
||||||
|
for (int y = horizon + 1; y < height; y++) {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
int move = (shift * 2 + y) % width;
|
||||||
|
// simple wave pattern for terrain / hill
|
||||||
|
char c;
|
||||||
|
if (((x + move) % 7) == 0)
|
||||||
|
c = '^';
|
||||||
|
else if (((x + move) % 5) == 0)
|
||||||
|
c = '`';
|
||||||
|
else
|
||||||
|
c = ' ';
|
||||||
|
printf("%c", c);
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// optional text overlay at bottom
|
||||||
if (text && text[0] != '\0') {
|
if (text && text[0] != '\0') {
|
||||||
printf("\r\n[RX] %s\r\n", text);
|
printf("\r\n[RX] %s\r\n", text);
|
||||||
}
|
}
|
||||||
@@ -77,7 +105,7 @@ int main(void)
|
|||||||
// shift = (shift + 1) % 8;
|
// shift = (shift + 1) % 8;
|
||||||
|
|
||||||
// }
|
// }
|
||||||
if (anim_timer.elapsed_time() >= 100ms) {
|
if (anim_timer.elapsed_time() >= 200ms) {
|
||||||
shift = (shift + 1) % 8;
|
shift = (shift + 1) % 8;
|
||||||
anim_timer.reset();
|
anim_timer.reset();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user