- First complete version of firmware. Currently being tested in the rehearsal room

- Added bunch of screens, fonts and images
 - Added script to read out frame buffer (function currently disabled in Firmware)
This commit is contained in:
2025-10-26 20:57:58 +01:00
parent 90bca063e6
commit 89c875e38f
62 changed files with 4668 additions and 489 deletions

View File

@@ -22,15 +22,17 @@
#include "INA260.h"
#include "Switch.h"
#include "Screens.h"
#include "EEPROM_M24C64.h"
#include "Rotary_Encoder.h"
#include "Display.h"
#include "Display_SPI.h"
#include "Display_Image.h"
#include "Screens.h"
#include "Display_Default_Configurations.h"
#include "USB_Serial.h"
#include "Serial_Command.h"
// ============================================================================================
@@ -64,11 +66,20 @@ extern uint16_t _Image_Power_Critical_32x32[];
extern uint16_t _Image_Power_Overvoltage_32x32[];
extern uint16_t _Image_Power_Undervoltage_32x32[];
extern uint16_t _Image_Power_Unplugged_32x32[];
extern uint16_t _Image_Overcurrent_32x32[];
static uint32_t _Idle_Counter;
// ============================================================================================
// Function Declarations
void Check_For_Serial_Input(void);
void Parse_Command(void);
void Serial_Send_Configuration_Text(void);
void Serial_Send_Configuration_Hex(void);
void Serial_Return_Ping(void);
void Serial_Write_Configuration_Byte(void);
void Serial_Save_To_EEPROM(void);
void Display_Start_Buffer_Readout(void);
@@ -96,7 +107,10 @@ int main(void)
// Trigger =================================================
TRIGGER_CONFIG;
TRIGGER_OFF;
// Serial Command =============================================
Serial_Command_Init();
// USB Serial =================================================
USB_Serial_Init();
@@ -120,8 +134,8 @@ int main(void)
// Display =================================================
Display_Init(DISPLAY_COLOR_BLACK, true, false);
// Screen_Setup_Loading();
Screen_Setup_Menu_Main(TRANSITION_NONE, TRANSITION_NONE, LINEAR, 0, false, 3);
Screen_Setup_Loading();
// Screen_Setup_Menu_Main(TRANSITION_NONE, TRANSITION_NONE, LINEAR, 0, false, 3);
// Rotary Encoder =============================================
Rotary_Encoder_Init();
@@ -135,6 +149,7 @@ int main(void)
// Repeating Timer =============================================
add_repeating_timer_ms(40, ISR_Repeating_Timer, NULL, &_Timer);
_Idle_Counter = 0;
while (1)
{
@@ -150,9 +165,29 @@ int main(void)
UI_Control_Acceleration_Update(CURRENT_TIME_ms);
INA260_Read_BusVoltage();
INA260_Update_Current_Threshold();
INA260_Read_BusVoltage();
INA260_Read_Current();
Command_Issue_Set_Request(MULTICORE_COMMAND_SET_INA260_BUSVOLTAGE, 0, INA260_Get_BusVoltage_mV());
if(_EEPROM_Content.Device_Configuration.Screen_Timeout > 0)
{
if(_Idle_Counter >= _EEPROM_Content.Device_Configuration.Screen_Timeout * (1000 / 40))
{
if(_Screen_Idle_Active != true)
{
Screen_Setup_Idle(TRANSITION_UP, TRANSITION_UP, SCREEN_TRANSITION_DEFAULT_EASING, SCREEN_TRANSITION_DEFAULT_FRAMES);
}
}
else if(_Screen_Idle_Counter_Disable == false)
{
_Idle_Counter++;
}
else if(_Screen_Idle_Counter_Disable == true)
{
_Idle_Counter = 0;
}
}
}
// Add functions here to execute during the DMA Transfer
@@ -164,6 +199,9 @@ int main(void)
if(Display_Send_Buffer_Completed())
{
TRIGGER_ON;
Mode_Manager_Tick();
EEPROM_Tick();
Command_Issue_Get_Request(MULTICORE_COMMAND_GET_LED_POWER_ERROR, 0);
Display_Render_Objects();
LED_Power_Error Error = Command_Get_Request_Response_By_Command_Only(MULTICORE_COMMAND_GET_LED_POWER_ERROR, 100);
@@ -176,6 +214,7 @@ int main(void)
case BUS_UNDERVOLTAGE: Image = _Image_Power_Undervoltage_32x32; break;
case BUS_OVERVOLTAGE: Image = _Image_Power_Overvoltage_32x32; break;
case BUS_VOLTAGE_MEASUREMENT: Image = _Image_Power_Critical_32x32; break;
case OVERCURRENT: Image = _Image_Overcurrent_32x32; break;
}
if(Image != NULL && Display_Screen_Transition_Ongoing() == false) {
@@ -185,84 +224,31 @@ int main(void)
}
else
{
Check_For_Serial_Input();
Serial_Command_Check_For_Input();
if(Rotary_Encoder_Rotation_CW_Occurred()) {
_Idle_Counter = 0;
Display_Action_CW();
}
if(Rotary_Encoder_Rotation_CCW_Occurred()) {
_Idle_Counter = 0;
Display_Action_CCW();
}
if(Rotary_Encoder_Switch_Press_Occurred()) {
_Idle_Counter = 0;
Display_Action_SW();
}
if(Switch_Press_Occurred()) {
if(_Screen_Idle_Active == false) {
_Idle_Counter = 0;
}
Mode_Manager_Cycle_Mode();
}
}
}
}
void Check_For_Serial_Input(void)
{
int Analog_Data = -1;
int i;
while(USB_Serial_Available())
{
uint8_t USB_Data = USB_Serial_Get_Byte();
switch(USB_Data)
{
case 'a':
USB_SERIAL_SEND_STRING("SPI Baudrate: ");
USB_Serial_Send_Int_Dec(Display_SPI_Get_Baudrate(), 10);
USB_SERIAL_SEND_TERMINATOR();
break;
case 'b': // New command for buffer readout
Display_Start_Buffer_Readout();
break;
case 'c':
Command_Issue_Get_Request(MULTICORE_COMMAND_GET_ANALOG_VOLTAGE, 0);
Analog_Data = Command_Get_Request_Response_By_Command_Only(MULTICORE_COMMAND_GET_ANALOG_VOLTAGE, 100);
USB_SERIAL_SEND_STRING("Analog: "); USB_Serial_Send_Int_Dec(Analog_Data, 5); USB_SERIAL_SEND_STRING("mV"); USB_SERIAL_SEND_TERMINATOR();
USB_SERIAL_SEND_STRING("INA260: "); USB_Serial_Send_Int_Dec(INA260_Get_BusVoltage_mV(), 5); USB_SERIAL_SEND_STRING("mV"); USB_SERIAL_SEND_TERMINATOR();
break;
default:
USB_SERIAL_SEND_STRING("Unknown Command: ");
USB_Serial_Put_Char(USB_Data);
USB_SERIAL_SEND_STRING(" (");
USB_Serial_Send_Int_Hex(USB_Data, 2, true);
USB_SERIAL_SEND_STRING(")");
USB_SERIAL_SEND_TERMINATOR();
break;
}
}
}
void Display_Start_Buffer_Readout(void)
{
cancel_repeating_timer(&_Timer);
// Send header
USB_SERIAL_SEND_STRING("IMGBUF");
USB_Serial_Send_Int_Dec(DISPLAY_WIDTH, 4);
USB_Serial_Put_Char(',');
USB_Serial_Send_Int_Dec(DISPLAY_HEIGHT, 4);
USB_Serial_Put_Char(',');
USB_Serial_Send_Int_Dec(16, 2);
USB_SERIAL_SEND_TERMINATOR();
uint32_t Pixel_Count = DISPLAY_WIDTH * DISPLAY_HEIGHT;
for(uint32_t i = 0; i < Pixel_Count; i++)
{
Display_Color Pixel = Display_Get_Pixel(i);
USB_Serial_Send_Int_Hex(Pixel, 4, false);
}
sleep_ms(100);
USB_SERIAL_SEND_TERMINATOR();
add_repeating_timer_ms(40, ISR_Repeating_Timer, NULL, &_Timer);
}