snake_compiler git · main
Snake compiled to a bare-metal RISC-V microcontroller
C 95.2% Markdown 3.3%git clone https://git.christianimmanuel.de/embedded/snake_compiler.gitwget https://git.christianimmanuel.de/embedded/snake_compiler/archive/snake_compiler.tar.gzsnake_SDL/src/matrix.h raw
#ifndef MATRIX_H
#define MATRIX_H
#include <mdk.h>
#include <stdint.h>
#include <stdbool.h>
#include "defaults.h"
#include "snake.h"
typedef enum GameMode_e {
NORMAL,
FANCY,
GAME_MODE_LAST,
} GameMode;
typedef enum PixelType_e {
NONE,
SNAKE,
APPLE,
} PixelType;
typedef struct Pixel_s {
Color color;
PixelType type;
} Pixel;
typedef struct LEDMatrix_s {
Pixel pixels[MATRIX_HEIGHT][MATRIX_WIDTH];
} LEDMatrix;
typedef struct {
int pin;
bool state_init;
bool state_prev;
bool state_curr;
} Button;
extern GameMode game_mode;
extern LEDMatrix* matrix;
extern Button* button_1;
extern Button* button_2;
extern Button* button_3;
extern Button* button_4;
int random_Int(int max);
void
matrix_Init(Color color);
void
matrix_SetPixelColor(int x, int y, Color c);
void
matrix_ToMdkBuffer();
void
matrix_WriteLed();
void
matrix_ClearAll(Color color);
void
matrix_Blink(int count, unsigned long delay_millis);
void
matrix_Print();
void
matrix_Update();
#endif