add firmware
This commit is contained in:
parent
f165ccdc95
commit
580bc8716c
21 changed files with 6148 additions and 0 deletions
23
firmware/main/include/iic.h
Normal file
23
firmware/main/include/iic.h
Normal 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);
|
||||
9
firmware/main/include/lcd/FontBase.h
Normal file
9
firmware/main/include/lcd/FontBase.h
Normal 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;
|
||||
1756
firmware/main/include/lcd/FontComicSansMS16.h
Normal file
1756
firmware/main/include/lcd/FontComicSansMS16.h
Normal file
File diff suppressed because it is too large
Load diff
1351
firmware/main/include/lcd/FontLiberationMono12.h
Normal file
1351
firmware/main/include/lcd/FontLiberationMono12.h
Normal file
File diff suppressed because it is too large
Load diff
1748
firmware/main/include/lcd/SymbolsFont.h
Normal file
1748
firmware/main/include/lcd/SymbolsFont.h
Normal file
File diff suppressed because it is too large
Load diff
97
firmware/main/include/lcd/ssd1306.h
Normal file
97
firmware/main/include/lcd/ssd1306.h
Normal 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);
|
||||
28
firmware/main/include/led/ws2811.h
Normal file
28
firmware/main/include/led/ws2811.h
Normal 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();
|
||||
34
firmware/main/include/ui/inputs.h
Normal file
34
firmware/main/include/ui/inputs.h
Normal 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();
|
||||
Loading…
Add table
Add a link
Reference in a new issue