/* * File: Screen_Graph.c * * Created: Created: Thursday August 2025 12:59:42 * Author: Chris */ // ============================================================================================ // Includes #include "../Screens.h" #include "../UI_Control.h" #include "../Command_Definition.h" #include "../Display.h" #include "../Display_Font.h" #include "../Display_Objects.h" #include "../Display_Default_Configurations.h" #include "../INA260.h" #include "../EEPROM_M24C64.h" // ============================================================================================ // Defines #define GRAPH_DATA_WDITH 200 #define COLOR_DARKGREEN DISPLAY_COLOR_FROM_RGB888(0, 100, 0) // ============================================================================================ // Variables extern const unsigned char _Font_DejaVu_Sans_Mono_6x12[]; extern const unsigned char _Font_DejaVu_Sans_Mono_10x17[]; extern const unsigned char _Font_DejaVu_Sans_Mono_Bold_7x15[]; extern const unsigned char _Font_DejaVu_Sans_Mono_Bold_11x17[]; static Object_ID _Object_Value_BusVoltage; static Object_ID _Object_Value_Current; static uint16_t _Data_BusVoltage[GRAPH_DATA_WDITH]; static uint16_t _Data_Current[GRAPH_DATA_WDITH]; static uint16_t _Data_Threshold_Current[GRAPH_DATA_WDITH]; static float _Actual_BusVoltage_V; static float _Actual_Current_A; // ============================================================================================ // Function Declarations void Screen_Setup_Graph(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration); static void Screen_Init (Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration); static void Screen_Tick (void); static void Screen_Click (uint button_return_value); static void Screen_Touch_Event (int16_t x, int16_t y); static void Screen_Action_CW (Object_ID object_id); static void Screen_Action_CCW (Object_ID object_id); static void Screen_On_Object_Focused (Object_ID object_id); static void Screen_On_Object_Defocused (Object_ID object_id); static void Screen_On_Object_Select (Object_ID object_id); static void Screen_On_Object_Deselect (Object_ID object_id); /******************************************************************* Functions *******************************************************************/ void Screen_Setup_Graph(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration) { Screen_Init(direction_out, direction_in, type, frame_duration); for(int i=0;i= 149)) { Current_Threshold_Label_Y += (Font_6_1_Height + 1); } else if((Current_Threshold_Label_Y <= 149) && (Current_Threshold_Label_Y >= 141)) { Current_Threshold_Label_Y = 141; } Font_ID Font_6_1 = Display_Objects_Add_Font(_Font_DejaVu_Sans_Mono_6x12, 1); Font_ID Font_10_1 = Display_Objects_Add_Font(_Font_DejaVu_Sans_Mono_10x17, 1); Font_ID Font_7_1_B = Display_Objects_Add_Font(_Font_DejaVu_Sans_Mono_Bold_7x15, 1); Font_ID Font_11_1_B = Display_Objects_Add_Font(_Font_DejaVu_Sans_Mono_Bold_11x17, 1); // Threshold Lines / Areas Display_Objects_Add_Rectangle_Frame(CENTER_TOP, X_IN_PERCENT_Y_IN_PIXEL, 50, 141, NOT_SELECTABLE, COLOR_DARKGREEN, GRAPH_DATA_WDITH+2, 8, 1, NO_STYLE, NO_ANIMATION); Display_Objects_Add_Graph(CENTER_MIDDLE, BOTH_IN_PERCENT, 50, 50, false, _Data_Threshold_Current, GRAPH_DATA_WDITH, 5000, 0, DISPLAY_COLOR_ORANGE, 200, NO_STYLE, NO_ANIMATION); // Threshold Labels Display_Objects_Add_Text(LEFT_BOTTOM, BOTH_IN_PIXEL, 19, 140, NOT_SELECTABLE, "12.5V", Font_6_1, COLOR_DARKGREEN, NO_STYLE, NO_ANIMATION); Display_Objects_Add_Text(LEFT_TOP , BOTH_IN_PIXEL, 19, 149, NOT_SELECTABLE, "11.5V", Font_6_1, COLOR_DARKGREEN, NO_STYLE, NO_ANIMATION); Display_Objects_Add_Text(CENTER_BOTTOM, X_IN_PERCENT_Y_IN_PIXEL, 50, Current_Threshold_Label_Y, NOT_SELECTABLE, Current_Threshold, Font_6_1, DISPLAY_COLOR_ORANGE, NO_STYLE, NO_ANIMATION); // Data Graphs (Voltage and Current) Display_Objects_Add_Graph(CENTER_MIDDLE, BOTH_IN_PERCENT, 50, 50, false, _Data_BusVoltage, GRAPH_DATA_WDITH, 32000, 0, DISPLAY_COLOR_RED, 200, NO_STYLE, NO_ANIMATION); Display_Objects_Add_Graph(CENTER_MIDDLE, BOTH_IN_PERCENT, 50, 50, false, _Data_Current, GRAPH_DATA_WDITH, 5000, 0, DISPLAY_COLOR_YELLOW, 200, NO_STYLE, NO_ANIMATION); // Data Values (Voltage and Current) _Object_Value_BusVoltage = Display_Objects_Add_Float(RIGHT_MIDDLE, X_IN_PERCENT_Y_IN_PIXEL, 48, 50, NOT_SELECTABLE, &_Actual_BusVoltage_V, "%2.1fV", Font_11_1_B, DISPLAY_COLOR_WHITE, NO_STYLE, NO_ANIMATION); _Object_Value_Current = Display_Objects_Add_Float(LEFT_MIDDLE, X_IN_PERCENT_Y_IN_PIXEL, 52, 50, NOT_SELECTABLE, &_Actual_Current_A, "%1.3fA", Font_11_1_B, DISPLAY_COLOR_YELLOW, NO_STYLE, NO_ANIMATION); } void Screen_Tick(void) { Display_Objects_Update_Coordinates(_Object_Value_BusVoltage, RIGHT_MIDDLE, X_IN_PERCENT_Y_IN_PIXEL, 48, 50); Display_Objects_Update_Coordinates(_Object_Value_Current, LEFT_MIDDLE, X_IN_PERCENT_Y_IN_PIXEL, 52, 50); for(int i=0;i