- Fixed drawing of round objects (Circles, Rounded Rects) using a lookup table

- Added function to read out the display_buffer via USB-Serial
 - Added basic structure and files for later complete firmware (still in progress)
 - Added Doc folder with schematic in it
 - Added Python script and batch file to read out the display buffer and open the image in gimp
This commit is contained in:
2025-09-07 08:55:39 +02:00
parent 714b5be13c
commit 128d42c586
66 changed files with 29943 additions and 225 deletions

View File

@@ -16,6 +16,16 @@
// Defines
#define INA260_I2CADDR_DEFAULT 0x40 ///< INA260 default i2c address
#define INA260_CONGIG_RST_BIT 15
#define INA260_CONGIG_AVG0_BIT 9
#define INA260_CONGIG_VBUSCT0_BIT 6
#define INA260_CONGIG_ISHCT0_BIT 3
#define INA260_CONGIG_MODE1_BIT 0
#define INA260_ENABLE_OCL_BIT 15
#define INA260_ENABLE_APOL_BIT 1
#define INA260_ENABLE_LEN_BIT 0
#define UINT8_ARR_TO_UINT16(_U8_) ((uint16_t)(_U8_[0]) << 8) | (uint16_t)(_U8_[1])
@@ -72,10 +82,13 @@ typedef enum _INA260_AlertLatch {
// ============================================================================================
// Variables
static uint16_t _INA260_BusVoltage_mV;
static uint16_t _INA260_Current_mA;
// ============================================================================================
// Function Declarations
uint16_t INA260_Read_Register(uint8_t reg_address);
/*******************************************************************
@@ -83,10 +96,55 @@ typedef enum _INA260_AlertLatch {
*******************************************************************/
void INA260_Init()
{
_INA260_BusVoltage_mV = 0;
_INA260_Current_mA = 0;
uint16_t Configuration_Register_Value =
(0 << INA260_CONGIG_RST_BIT) | // No Reset
(INA260_COUNT_1 << INA260_CONGIG_AVG0_BIT) | // Averaging Count
(INA260_TIME_8_244_ms << INA260_CONGIG_VBUSCT0_BIT) | // Bus Voltage Conversion Time
(INA260_TIME_8_244_ms << INA260_CONGIG_ISHCT0_BIT) | // Shunt Current Conversion Time
(INA260_MODE_CONTINUOUS << INA260_CONGIG_MODE1_BIT); // Operating Mode
I2CM_Packet_Transmit(INA260_I2CADDR_DEFAULT, INA260_REG_CONFIG, 1, (uint8_t*)(&Configuration_Register_Value), 2);
uint16_t Enable_Register_Value =
(1 << INA260_ENABLE_OCL_BIT) | // Over Current Limit
(0 << INA260_ENABLE_APOL_BIT) | // Alert Polarity Bit
(1 << INA260_ENABLE_LEN_BIT); // Alert Latch Enable
I2CM_Packet_Transmit(INA260_I2CADDR_DEFAULT, INA260_REG_MASK_ENABLE, 1, (uint8_t*)(&Enable_Register_Value), 2);
}
uint16_t INA260_Test_Read(uint8_t reg_address)
void INA260_Read_BusVoltage()
{
uint32_t INA260_BusVoltage = (uint32_t)INA260_Read_Register(INA260_REG_BUSVOLTAGE);
_INA260_BusVoltage_mV = (int16_t)((INA260_BusVoltage * 1250) / 1000);
}
void INA260_Read_Current()
{
uint32_t INA260_Current = (uint32_t)INA260_Read_Register(INA260_REG_CURRENT);
_INA260_Current_mA = (int16_t)((INA260_Current * 1250) / 1000);
}
uint16_t INA260_Get_BusVoltage_mV()
{
return _INA260_BusVoltage_mV;
}
uint16_t INA260_Get_Current_mA()
{
return _INA260_Current_mA;
}
/*******************************************************************
Internal Functions
*******************************************************************/
uint16_t INA260_Read_Register(uint8_t reg_address)
{
uint8_t Receive_Data[2];
@@ -94,9 +152,3 @@ uint16_t INA260_Test_Read(uint8_t reg_address)
return UINT8_ARR_TO_UINT16(Receive_Data);
}
/*******************************************************************
Internal Functions
*******************************************************************/