add firmware

This commit is contained in:
digimint 2026-01-22 19:54:53 -06:00
parent f165ccdc95
commit 580bc8716c
Signed by: digimint
GPG key ID: 8DF1C6FD85ABF748
21 changed files with 6148 additions and 0 deletions

View file

@ -0,0 +1,23 @@
/* MX-008 "Onyx Sovereign" -02 "Kingmaker"
* ============================================================================
* === IIC interface configuration
* ============================================================================
*
* Alexis Maya-Isabelle Shuping
* 29th March 2021
* University of Florida
*/
#pragma once
#include <driver/i2c.h>
#define T_IIC_INIT ("IIC INIT")
#define T_IIC_LCD ("IICL")
#define IIC_NUM_LCD (I2C_NUM_0)
void iicInit(i2c_port_t port, int sclNum, int sdaNum, bool pullUps, int clkRate);
void iicCommand(i2c_port_t port, uint_fast8_t targetAddress, uint_fast8_t toSend);
void iicData(i2c_port_t port, uint_fast8_t targetAddress, uint_fast8_t toSend);

View file

@ -0,0 +1,9 @@
#pragma once
#include <stdint.h>
typedef struct font_t {
const char* fTable;
uint16_t width;
uint16_t height;
uint16_t cSize;
} font_t;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,97 @@
/**
* ============================================================================
* === SSD1306 128x64 IIC LCD Interface
* ============================================================================
*
* Provides a simple interface for rendering text to an SSD1306 LCD.
*
* digimint
*/
#pragma once
#include "FontComicSansMS16.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdbool.h>
#include <stdint.h>
// LCD target address
#define IIC_LCD_ADDR (0x3C)
#define LCD_TAG "LCD"
extern uint8_t LCD_data[8][128];
extern bool LCD_rowChanged[8];
/**
* Initialize the LCD interface.
*
* This command configures the IIC bus, sends the proper initialization commands
* to the LCD, and spawns a task to update the display regularly.
*
* @param updateTaskHandle If this variable is not NULL, a handle to the display
* update task will be stored in it.
*/
void LCD_init(TaskHandle_t* updateTaskHandle);
/**
* Render a single character to the LCD buffer.
*
* @warning This function does not perform bounds checking.
*
* @param font The font to use for text rendering.
* @param oChr The character to render.
* @param x The x-coordinate for the top-left of the character.
* @param y The y-coordinate for the top-left of the character.
* @param invert Whether the character should be inverted before display.
*/
void LCD_renderChar(font_t font, const char oChr, uint16_t x, uint16_t y, bool invert);
/**
* Render text to the LCD buffer.
*
* @warning This function does not protect against buffer overrun.
*
* @param font The font to use for text rendering.
* @param str The text to render.
* @param x The x-coordinate for the top-left of the first character.
* @param y The y-coordinate for the top-left of the first character.
* @param invert Whether the character should be inverted before display.
*/
void LCD_renderText(font_t font, const char* str, uint16_t x, uint16_t y, bool invert);
/**
* Render text in Comic Sans
*
* A convenience macro that expands to
*
* `LCD_renderText(FontComicSansMS16, str, x, y);`
*/
static inline void LCD_renderTextCS(const char* str, uint16_t x, uint16_t y){
LCD_renderText(FontComicSansMS16, str, x, y, false);
}
/**
* Manually force an immediate update of the LCD.
*
* Note that this function will be called automatically by the LCD update task
* during normal operation, so it generally should not be manually invoked.
*
* A semaphore is used to ensure that only one task attempts to communicate with
* the display at a time.
*
* @param block If true, then the calling task will block until the LCD is
* available for communication. Otherwise, if the LCD is not immediately
* available, the function will simply return `false`.
*
* @return `true` if the LCD was successfully updated; `false` otherwise.
*
* @note This function will only return false if two conditions apply:
* (1) `block` is false; and
* (2) The LCD semaphore has been taken (i.e. the LCD is currently busy)
*/
bool LCD_updateDisplay(bool block);

View file

@ -0,0 +1,28 @@
#pragma once
#include <esp_attr.h>
#include <stdint.h>
#include <stddef.h>
#define LED_PIN (23)
typedef enum LEDStripSpeed{
WS2811_LOW_SPEED = 10000000, // One tick == 0.1us
WS2811_HIGH_SPEED = 20000000 // One tick == 0.05us
} LEDStripSpeed_t;
typedef struct PACKED_ATTR rgbPacket {
uint8_t r;
uint8_t g;
uint8_t b;
} rgbPacket_t;
typedef void (*ledRenderFunction_t)(
rgbPacket_t* buf,
size_t led_count,
unsigned long frame
);
extern uint8_t saturation;
void init_leds();

View file

@ -0,0 +1,34 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/event_groups.h>
#define INPUTS_TAG ("INPUT")
extern TaskHandle_t T_ReadInputs_Handle;
extern EventGroupHandle_t EV_InputEventGroupHandle;
typedef enum InputEventGroupFlags {
INPUT_EVENT_WHEEL = (1 << 0),
INPUT_EVENT_KEY_FORWARD = (1 << 1),
INPUT_EVENT_KEY_BACKSPACE = (1 << 2),
INPUT_EVENT_KEY_DONE = (1 << 3),
INPUT_EVENT_KEY_CANCEL = (1 << 4),
INPUT_EVENT_KEY_OPTION = (1 << 5)
} UIEventGroupFlags_t;
typedef struct InputState {
bool forward, backspace, done, cancel, option;
int wheel;
uint8_t _wheelQuadrant;
} InputState_t;
void init_inputs();
InputState_t waitForInputEvents(UIEventGroupFlags_t events, BaseType_t xWaitForAll, TickType_t xTicksToWait);
InputState_t getInputState();