Commit 870cb6f8 authored by matt's avatar matt
Browse files

Fix GCC warnings

Some were found with the addition of -Wshadow.

Mostly just casting (e.g. dropping volatile), but also some unused
variables were commented out, and an out of bounds array access was
fixed in Ui_SoftBar_Setup().

Pragmas were added to silence strict-aliasing warnings, and the affected
macros were reformatted for better readability.

With the addition of these changes, no warnings are seen during the
firmware build.
parent e0cfc5af
......@@ -9,7 +9,9 @@
#include "hal.h"
static const char* TAG = "BatteryMgr";
#if defined HWVER_PORTABLE
static esp_adc_cal_characteristics_t *BatteryMgr_AdcChars;
#endif
uint16_t BatteryMgr_Voltage = 0;
bool BatteryMgr_Setup() {
......@@ -54,4 +56,4 @@ void BatteryMgr_Main() {
#endif
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
\ No newline at end of file
}
......@@ -31,14 +31,49 @@ static uint8_t DsFind_VgmBuf[FREAD_LOCAL_BUF];
static uint16_t DsFind_VgmBufPos = FREAD_LOCAL_BUF;
static IRAM_ATTR uint32_t DsFind_VgmFilePos = 0;
#define DSFIND_BUF_FILL fseek(DacStream_FindFile, DsFind_VgmFilePos, SEEK_SET); fread(&DsFind_VgmBuf[0], 1, sizeof(DsFind_VgmBuf), DacStream_FindFile); DsFind_VgmBufPos = 0; //todo fix read past eof
#define DSFIND_BUF_CHECK if (DsFind_VgmBufPos >= sizeof(DsFind_VgmBuf)) {DSFIND_BUF_FILL;}
#define DSFIND_BUF_SEEK_SET(offset) DsFind_VgmFilePos = offset; fseek(DacStream_FindFile, offset, SEEK_SET); DSFIND_BUF_FILL;
#define DSFIND_BUF_SEEK_REL(offset) DsFind_VgmFilePos += offset; DsFind_VgmBufPos += offset; DSFIND_BUF_CHECK;
#define DSFIND_BUF_READ(var) var = DsFind_VgmBuf[DsFind_VgmBufPos]; DsFind_VgmBufPos++; DsFind_VgmFilePos++; DSFIND_BUF_CHECK;
#define DSFIND_BUF_READ4(var) if (sizeof(DsFind_VgmBuf)-DsFind_VgmBufPos < 4) {DSFIND_BUF_FILL;} var = *(uint32_t*)&DsFind_VgmBuf[DsFind_VgmBufPos]; DsFind_VgmBufPos += 4; DsFind_VgmFilePos += 4; DSFIND_BUF_CHECK;
#define DSFIND_BUF_READ2(var) if (sizeof(DsFind_VgmBuf)-DsFind_VgmBufPos < 2) {DSFIND_BUF_FILL;} var = *(uint16_t*)&DsFind_VgmBuf[DsFind_VgmBufPos]; DsFind_VgmBufPos += 2; DsFind_VgmFilePos += 2; DSFIND_BUF_CHECK;
#define DSFIND_BUF_FILL \
fseek(DacStream_FindFile, DsFind_VgmFilePos, SEEK_SET); \
fread(&DsFind_VgmBuf[0], 1, sizeof(DsFind_VgmBuf), DacStream_FindFile); \
DsFind_VgmBufPos = 0; //todo fix read past eof
#define DSFIND_BUF_CHECK \
if (DsFind_VgmBufPos >= sizeof(DsFind_VgmBuf)) { \
DSFIND_BUF_FILL; \
}
#define DSFIND_BUF_SEEK_SET(offset) \
DsFind_VgmFilePos = offset; \
fseek(DacStream_FindFile, offset, SEEK_SET); \
DSFIND_BUF_FILL;
#define DSFIND_BUF_SEEK_REL(offset) \
DsFind_VgmFilePos += offset; \
DsFind_VgmBufPos += offset; \
DSFIND_BUF_CHECK;
#define DSFIND_BUF_READ(var) \
var = DsFind_VgmBuf[DsFind_VgmBufPos]; \
DsFind_VgmBufPos++; \
DsFind_VgmFilePos++; \
DSFIND_BUF_CHECK;
#define DSFIND_BUF_READ4(var) \
if (sizeof(DsFind_VgmBuf)-DsFind_VgmBufPos < 4) { \
DSFIND_BUF_FILL; \
} \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wstrict-aliasing\"") \
var = *(uint32_t*)&DsFind_VgmBuf[DsFind_VgmBufPos]; \
_Pragma("GCC diagnostic pop") \
DsFind_VgmBufPos += 4; \
DsFind_VgmFilePos += 4; \
DSFIND_BUF_CHECK;
#define DSFIND_BUF_READ2(var) \
if (sizeof(DsFind_VgmBuf)-DsFind_VgmBufPos < 2) { \
DSFIND_BUF_FILL; \
} \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wstrict-aliasing\"") \
var = *(uint16_t*)&DsFind_VgmBuf[DsFind_VgmBufPos]; \
_Pragma("GCC diagnostic pop") \
DsFind_VgmBufPos += 2; \
DsFind_VgmFilePos += 2; \
DSFIND_BUF_CHECK;
bool DacStream_Setup() {
ESP_LOGI(TAG, "Setting up");
......@@ -47,7 +82,7 @@ bool DacStream_Setup() {
for (uint8_t i=0; i<DACSTREAM_PRE_COUNT; i++) {
DacStreamEntries[i].SlotFree = true;
DacStreamEntries[i].Seq = 0;
MegaStream_Create(&DacStreamEntries[i].Stream, &Driver_PcmBuf[i*DACSTREAM_BUF_SIZE], DACSTREAM_BUF_SIZE);
MegaStream_Create((MegaStreamContext_t *)&DacStreamEntries[i].Stream, &Driver_PcmBuf[i*DACSTREAM_BUF_SIZE], DACSTREAM_BUF_SIZE);
}
ESP_LOGI(TAG, "Creating find thread status event group");
......@@ -158,10 +193,10 @@ void DacStream_FindTask() {
if (!VgmCommandIsFixedSize(d)) {
if (d == 0x67) { //datablock
if (DacStream_CurLoop == 0) { //only load datablocks on first loop through
VgmParseDataBlock(DacStream_FindFile, &DacStream_VgmDataBlocks[DacStream_VgmDataBlockIndex++]);
VgmParseDataBlock(DacStream_FindFile, (VgmDataBlockStruct_t *)&DacStream_VgmDataBlocks[DacStream_VgmDataBlockIndex++]);
} else {
//can't simply skip over the datablock because they're variable-length. use the last entry as a garbage can
VgmParseDataBlock(DacStream_FindFile, &DacStream_VgmDataBlocks[MAX_REALTIME_DATABLOCKS]);
VgmParseDataBlock(DacStream_FindFile, (VgmDataBlockStruct_t *)&DacStream_VgmDataBlocks[MAX_REALTIME_DATABLOCKS]);
}
//todo: bounds check
}
......@@ -191,20 +226,18 @@ void DacStream_FindTask() {
//reset
DacStreamEntries[FreeSlot].ReadOffset = 0;
DacStreamEntries[FreeSlot].BytesFilled = 0;
MegaStream_Reset(&DacStreamEntries[FreeSlot].Stream);
MegaStream_Reset((MegaStreamContext_t *)&DacStreamEntries[FreeSlot].Stream);
DacStreamEntries[FreeSlot].SlotFree = false;
DacStream_FoundAny = true;
break;
} else if (d == 0x94) { //stop
DSFIND_BUF_SEEK_REL(1) //skip stream id
} else if (d == 0x95) { //fast start
uint8_t sid;
DSFIND_BUF_READ(sid)
DSFIND_BUF_SEEK_REL(1) //skip stream id
DSFIND_BUF_READ2(DacStream_CurDataBlock)
DacStreamEntries[FreeSlot].DataLength = DacStream_GetBlockSize(DacStream_CurDataBank, DacStream_CurDataBlock);
DacStreamEntries[FreeSlot].DataStart = DacStream_GetBlockOffset(DacStream_CurDataBank, DacStream_CurDataBlock);
uint8_t flags;
DSFIND_BUF_READ(flags)
DSFIND_BUF_SEEK_REL(1) //skip flags
//assign other attributes
DacStreamEntries[FreeSlot].DataBankId = DacStream_CurDataBank;
DacStreamEntries[FreeSlot].ChipCommand = DacStream_CurChipCommand;
......@@ -215,7 +248,7 @@ void DacStream_FindTask() {
DacStreamEntries[FreeSlot].LengthMode = 0; //always for fast starts
DacStreamEntries[FreeSlot].ReadOffset = 0;
DacStreamEntries[FreeSlot].BytesFilled = 0;
MegaStream_Reset(&DacStreamEntries[FreeSlot].Stream);
MegaStream_Reset((MegaStreamContext_t *)&DacStreamEntries[FreeSlot].Stream);
DacStreamEntries[FreeSlot].SlotFree = false;
DacStream_FoundAny = true;
break;
......@@ -257,7 +290,7 @@ bool DacStream_FillTask_DoPre(uint8_t idx) { //returns whether or not it had to
bool ret = false;
xSemaphoreTake(DacStream_Mutex, pdMS_TO_TICKS(1000));
if (!DacStreamEntries[idx].SlotFree) {
if (MegaStream_Free(&DacStreamEntries[idx].Stream) > DACSTREAM_BUF_SIZE/3 && DacStreamEntries[idx].ReadOffset < DacStreamEntries[idx].DataLength) {
if (MegaStream_Free((MegaStreamContext_t *)&DacStreamEntries[idx].Stream) > DACSTREAM_BUF_SIZE/3 && DacStreamEntries[idx].ReadOffset < DacStreamEntries[idx].DataLength) {
UserLedMgr_DiskState[DISKSTATE_DACSTREAM_FILL] = true;
UserLedMgr_Notify();
uint32_t o = DacStream_GetDataOffset(DacStreamEntries[idx].DataBankId, DacStreamEntries[idx].DataStart + DacStreamEntries[idx].ReadOffset);
......@@ -273,7 +306,7 @@ bool DacStream_FillTask_DoPre(uint8_t idx) { //returns whether or not it had to
dsbufused = 0;
ret = true;
}
uint32_t freespaces = MegaStream_Free(&DacStreamEntries[idx].Stream);
uint32_t freespaces = MegaStream_Free((MegaStreamContext_t *)&DacStreamEntries[idx].Stream);
//try to find a dead dacstream that has the data we need. has to be a dead one, any active ones might have data removed
while (freespaces && DacStreamEntries[idx].ReadOffset < DacStreamEntries[idx].DataLength) {
if (dsbufused == DACSTREAM_BUF_SIZE) {
......@@ -290,7 +323,7 @@ bool DacStream_FillTask_DoPre(uint8_t idx) { //returns whether or not it had to
uint32_t writesize = streamremaining;
if (dsbufremaining < writesize) writesize = dsbufremaining;
if (freespaces < writesize) writesize = freespaces;
MegaStream_Send(&DacStreamEntries[idx].Stream, &DacStream_FillBuf[dsbufused], writesize);
MegaStream_Send((MegaStreamContext_t *)&DacStreamEntries[idx].Stream, &DacStream_FillBuf[dsbufused], writesize);
dsbufused += writesize;
DacStreamEntries[idx].ReadOffset += writesize;
freespaces -= writesize;
......@@ -329,7 +362,7 @@ void DacStream_FillTask() {
bool ret = DacStream_FillTask_DoPre(idx);
if (++idx == DACSTREAM_PRE_COUNT) idx = 0;
if (!ret) { //if we didn't hit the card, that pre was basically "free", so go ahead with the next one right away
bool ret = DacStream_FillTask_DoPre(idx);
DacStream_FillTask_DoPre(idx);
if (++idx == DACSTREAM_PRE_COUNT) idx = 0;
}
vTaskDelay(pdMS_TO_TICKS(10));
......@@ -369,7 +402,7 @@ bool DacStream_BeginFinding(VgmDataBlockStruct_t *SourceBlocks, uint8_t SourceBl
return false;
}
ESP_LOGI(TAG, "Copying datablock array");
memcpy(&DacStream_VgmDataBlocks[0], SourceBlocks, sizeof(VgmDataBlockStruct_t)*SourceBlockCount);
memcpy((VgmDataBlockStruct_t *)&DacStream_VgmDataBlocks[0], SourceBlocks, sizeof(VgmDataBlockStruct_t)*SourceBlockCount);
DacStream_VgmDataBlockIndex = SourceBlockCount;
ESP_LOGI(TAG, "Seek to start offset");
DSFIND_BUF_SEEK_SET(StartOffset)
......@@ -410,4 +443,4 @@ bool DacStream_Stop() {
ESP_LOGE(TAG, "DacStream find task stop request timeout !!");
return false;
}
}
\ No newline at end of file
}
......@@ -471,7 +471,7 @@ void Driver_FmOutopna(uint8_t Port, uint8_t Register, uint8_t Value) {
ChannelMgr_States[6+3] |= CHSTATE_PARAM; //implicit noise update too, todo only do this if noise is enabled on that ch
} else if (Port == 0 && Register == 0x06) { //noise period
ChannelMgr_States[6+3] |= CHSTATE_PARAM;
} else if (Port == 0 && Register >= 0x00 && Register <= 0x05) { //coarse/fine tune
} else if (Port == 0 && Register <= 0x05) { //coarse/fine tune
ch = Register/2;
ChannelMgr_States[6+ch] |= CHSTATE_PARAM;
} //todo 0x08/0x0c env freq, 0x0d env wave. will need tracking of if channels have envgen enabled
......@@ -750,7 +750,7 @@ static uint8_t FadeSsgLevel(uint8_t level) {
}
static uint8_t FilterSsgLevelWrite(uint8_t cmd1, uint8_t cmd2) { //handles fades and channel muting config - channel muting handled ONLY to stop level change popping and SSGPCM!!
uint8_t ch = cmd1 - 0x08;
//uint8_t ch = cmd1 - 0x08;
if (FadeActive) {
cmd2 = FadeSsgLevel(cmd2);
}
......@@ -1124,10 +1124,13 @@ bool Driver_RunCommand(uint8_t CommandLength) { //run the next command in the st
}
Driver_FmOut(1, cmd[1], cmd[2]);
} else if (cmd[0] == 0x61) { //16bit wait
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wstrict-aliasing\"")
Driver_NextSample += *(uint16_t*)&cmd[1];
if (Driver_FirstWait && *(uint16_t*)&cmd[1] > 0) {
Driver_SetFirstWait();
}
_Pragma("GCC diagnostic pop")
} else if (cmd[0] == 0x62) { //60Hz wait
Driver_NextSample += 735;
if (Driver_FirstWait) Driver_SetFirstWait();
......@@ -1169,14 +1172,17 @@ bool Driver_RunCommand(uint8_t CommandLength) { //run the next command in the st
Driver_Cycle_Ds = 0;
DacStreamLengthMode = DacStreamEntries[DacStreamId].LengthMode;
DacStreamDataLength = DacStreamEntries[DacStreamId].DataLength;
ESP_LOGD(TAG, "playing %d q size %d rate %d LM %d len %d", DacStreamSeq, MegaStream_Used(&DacStreamEntries[DacStreamId].Stream), DacStreamSampleRate, DacStreamLengthMode, DacStreamDataLength);
ESP_LOGD(TAG, "playing %d q size %d rate %d LM %d len %d", DacStreamSeq, MegaStream_Used((MegaStreamContext_t *)&DacStreamEntries[DacStreamId].Stream), DacStreamSampleRate, DacStreamLengthMode, DacStreamDataLength);
DacStreamActive = true;
}
} else if (cmd[0] == 0x94) { //dac stream stop
DacStreamActive = false;
} else if (cmd[0] == 0x92) { //set sample rate
if (DacStreamActive) {
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wstrict-aliasing\"")
DacStreamSampleRate = *(uint32_t*)&cmd[2];
_Pragma("GCC diagnostic pop")
ESP_LOGD(TAG, "Dacstream samplerate updated to %d", DacStreamSampleRate);
//TODO: handle the math for updating the current sample number, if sample rate changes mid-stream
} else {
......@@ -1259,7 +1265,7 @@ void Driver_Main() {
Driver_PsgAttenuation[i] = 0b10011111 | (i<<5);
}
Driver_UpdateMuting();
memset(&ChannelMgr_States[0], 0, 6+4);
memset((void *)&ChannelMgr_States[0], 0, 6+4);
DacLastValue = 0;
DacTouched = false;
......@@ -1396,12 +1402,12 @@ void Driver_Main() {
//can't just go by bytes played because some play modes are based on time
//decide whether those are worth implementing
Driver_BusyStart = xthal_get_ccount();
if (MegaStream_Used(&DacStreamEntries[DacStreamId].Stream)) {
if (MegaStream_Used((MegaStreamContext_t *)&DacStreamEntries[DacStreamId].Stream)) {
Driver_Cycle_Ds += diff;
Driver_Sample_Ds = Driver_Cycle_Ds / (DRIVER_CLOCK_RATE/DacStreamSampleRate);
if (Driver_Sample_Ds > DacStreamSamplesPlayed) {
uint8_t sample;
MegaStream_Recv(&DacStreamEntries[DacStreamId].Stream, &sample, 1);
MegaStream_Recv((MegaStreamContext_t *)&DacStreamEntries[DacStreamId].Stream, &sample, 1);
if (Driver_DetectedMod == MEGAMOD_OPNA) {
Driver_FmOutopna(DacStreamPort, DacStreamCommand, sample);
} else {
......@@ -1464,4 +1470,4 @@ void Driver_Main() {
}
Driver_CpuPeriod += (xthal_get_ccount() - Driver_Cc);
}
}
\ No newline at end of file
}
......@@ -86,7 +86,6 @@ uint8_t I2cMgr_Clear() {
ets_delay_us(4);
}
ets_delay_us(10000);
bool fail = false;
if (!gpio_get_level(PIN_I2C_DATA)) {
ESP_LOGE(TAG, "I2C SDA appears to be stuck low");
return 1;
......@@ -102,4 +101,4 @@ uint8_t I2cMgr_Clear() {
return 3;
}
return 0;
}
\ No newline at end of file
}
......@@ -32,11 +32,11 @@ static uint8_t ss_id = 0;
static FILE *ss_file;
void LcdDma_PostTransferCallback(spi_transaction_t *t) {
if (/*!LcdDma_AltMode && */(uint8_t)t->user & 1<<1) lv_disp_flush_ready(disp);
if (/*!LcdDma_AltMode && */(uint8_t)(uintptr_t)t->user & 1<<1) lv_disp_flush_ready((lv_disp_drv_t *)disp);
}
void LcdDma_PreTransferCallback(spi_transaction_t *t) {
gpio_set_level(PIN_DISP_DC, (uint8_t)t->user); //no need to mask off the end of sequence bit - gpio driver just does "if (level)"
gpio_set_level(PIN_DISP_DC, (uint8_t)(uintptr_t)t->user); //no need to mask off the end of sequence bit - gpio driver just does "if (level)"
}
spi_device_interface_config_t LcdDma_SpiDeviceConfig = {
......@@ -145,7 +145,7 @@ static void LcdDma_Lvgl_Flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv
if (waiting) {
fwrite(ss_buf, 1, waiting, ss_file);
}
lv_disp_flush_ready(disp);
lv_disp_flush_ready((lv_disp_drv_t *)disp);
return;
}
......@@ -184,7 +184,7 @@ static void LcdDma_Lvgl_Flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv
spi_device_queue_trans(LcdDma_SpiDevice, &LcdDma_Flush_Txs[4], portMAX_DELAY);
LcdDma_Flush_Txs[5].tx_buffer = (uint8_t *)color_p;
LcdDma_Flush_Txs[5].length = pix<<4;
LcdDma_Flush_Txs[5].user = 0b11; //bit 1 used as end of sequence flag, checked in post-transfer callback
LcdDma_Flush_Txs[5].user = (void *)0b11; //bit 1 used as end of sequence flag, checked in post-transfer callback
spi_device_queue_trans(LcdDma_SpiDevice, &LcdDma_Flush_Txs[5], portMAX_DELAY);
ESP_LOGD(TAG, "Tx buf%d %d bytes", ((void *)color_p >= (void *)&LcdDma_Lvgl_Buf[0] && (void *)color_p < (void *)&LcdDma_Lvgl_Buf[LV_VDB_SIZE_IN_BYTES])?1:2, pix<<1);
......@@ -196,8 +196,8 @@ static void LcdDma_Lvgl_Flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv
esp_err_t err;
do {
err = spi_device_get_trans_result(LcdDma_SpiDevice, &check, pdMS_TO_TICKS(1000));
} while (err != ESP_OK || ((uint8_t)check->user & 1<<1) == 0);
lv_disp_flush_ready(disp);
} while (err != ESP_OK || ((uint8_t)(uintptr_t)check->user & 1<<1) == 0);
lv_disp_flush_ready((lv_disp_drv_t *)disp);
ESP_LOGD(TAG, "Alt mode flush successful");
}
}
......@@ -284,11 +284,11 @@ void LcdDma_Main() {
//these two draws should be identical, since there is no lv_tick_inc in between
LcdDma_Screenshot = false;
lv_obj_invalidate(lv_scr_act());
lv_refr_now(disp);
lv_refr_now((lv_disp_t *)disp);
LcdDma_Screenshot = true;
ss_start();
lv_obj_invalidate(lv_scr_act());
lv_refr_now(disp);
lv_refr_now((lv_disp_t *)disp);
ss_finish();
LcdDma_Screenshot = false;
} else {
......
......@@ -122,11 +122,11 @@ bool LedDrv_Update() {
led_pwm[led_channel_assignment[i]] = led_curve_lut[LedDrv_States[i]];
}
bool ret = LedDrv_WritePwmValues(0, &led_pwm[0]);
bool ret = LedDrv_WritePwmValues(0, (uint8_t *)&led_pwm[0]);
if (!ret) {
return false;
}
ret = LedDrv_WritePwmValues(1, &led_pwm[8]);
ret = LedDrv_WritePwmValues(1, (uint8_t *)&led_pwm[8]);
return ret;
}
......@@ -138,7 +138,7 @@ bool LedDrv_Setup() {
return false;
}
memset(&LedDrv_States[0], 0, sizeof(LedDrv_States));
memset((void *)&LedDrv_States[0], 0, sizeof(LedDrv_States));
ESP_LOGI(TAG, "Resetting...");
if (!LedDrv_Reset()) {
......@@ -192,4 +192,4 @@ void LedDrv_UpdateBrightness() {
LedDrv_WriteRegister(1, 0x0a, LedDrv_Brightness);
I2cMgr_Release(false);
}
\ No newline at end of file
}
......@@ -31,12 +31,38 @@ volatile bool Loader_FastOpnaUpload = false;
bool Loader_HitLoop = false;
//local buffer thingie. big speedup
#define LOADER_BUF_FILL fseek(Loader_File, Loader_VgmFilePos, SEEK_SET); fread(&Loader_VgmBuf[0], 1, sizeof(Loader_VgmBuf), Loader_File); Loader_VgmBufPos = 0; //todo fix read past eof
#define LOADER_BUF_CHECK if (Loader_VgmBufPos >= sizeof(Loader_VgmBuf)) {LOADER_BUF_FILL;}
#define LOADER_BUF_SEEK_SET(offset) Loader_VgmFilePos = offset; fseek(Loader_File, offset, SEEK_SET); LOADER_BUF_FILL;
#define LOADER_BUF_SEEK_REL(offset) Loader_VgmFilePos += offset; Loader_VgmBufPos += offset; LOADER_BUF_CHECK;
#define LOADER_BUF_READ(var) var = Loader_VgmBuf[Loader_VgmBufPos]; Loader_VgmBufPos++; Loader_VgmFilePos++; LOADER_BUF_CHECK;
#define LOADER_BUF_READ4(var) if (sizeof(Loader_VgmBuf)-Loader_VgmBufPos < 4) {LOADER_BUF_FILL;} var = *(uint32_t*)&Loader_VgmBuf[Loader_VgmBufPos]; Loader_VgmBufPos += 4; Loader_VgmFilePos += 4; LOADER_BUF_CHECK;
#define LOADER_BUF_FILL \
fseek(Loader_File, Loader_VgmFilePos, SEEK_SET); \
fread(&Loader_VgmBuf[0], 1, sizeof(Loader_VgmBuf), Loader_File); \
Loader_VgmBufPos = 0; //todo fix read past eof
#define LOADER_BUF_CHECK \
if (Loader_VgmBufPos >= sizeof(Loader_VgmBuf)) { \
LOADER_BUF_FILL; \
}
#define LOADER_BUF_SEEK_SET(offset) \
Loader_VgmFilePos = offset; \
fseek(Loader_File, offset, SEEK_SET); \
LOADER_BUF_FILL;
#define LOADER_BUF_SEEK_REL(offset) \
Loader_VgmFilePos += offset; \
Loader_VgmBufPos += offset; \
LOADER_BUF_CHECK;
#define LOADER_BUF_READ(var) \
var = Loader_VgmBuf[Loader_VgmBufPos]; \
Loader_VgmBufPos++; \
Loader_VgmFilePos++; \
LOADER_BUF_CHECK;
#define LOADER_BUF_READ4(var) \
if (sizeof(Loader_VgmBuf)-Loader_VgmBufPos < 4) { \
LOADER_BUF_FILL; \
} \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wstrict-aliasing\"") \
var = *(uint32_t*)&Loader_VgmBuf[Loader_VgmBufPos]; \
_Pragma("GCC diagnostic pop") \
Loader_VgmBufPos += 4; \
Loader_VgmFilePos += 4; \
LOADER_BUF_CHECK;
bool Loader_Setup() {
ESP_LOGI(TAG, "Setting up");
......@@ -164,10 +190,10 @@ void Loader_Main() {
//here are some hacks to wrap around VgmParseDataBlock not using our local buffer thing
fseek(Loader_File, Loader_VgmFilePos, SEEK_SET); //destroys buf
if (Loader_CurLoop == 0) { //only load datablocks on first loop through
VgmParseDataBlock(Loader_File, &Loader_VgmDataBlocks[Loader_VgmDataBlockIndex++]);
VgmParseDataBlock(Loader_File, (VgmDataBlockStruct_t *)&Loader_VgmDataBlocks[Loader_VgmDataBlockIndex++]);
} else {
//can't simply skip over the datablock because they're variable-length. use the last entry as a garbage can
VgmParseDataBlock(Loader_File, &Loader_VgmDataBlocks[MAX_REALTIME_DATABLOCKS]);
VgmParseDataBlock(Loader_File, (VgmDataBlockStruct_t *)&Loader_VgmDataBlocks[MAX_REALTIME_DATABLOCKS]);
}
LOADER_BUF_SEEK_SET(ftell(Loader_File)); //fix buf
......@@ -228,7 +254,7 @@ void Loader_Main() {
break;
} else if (d >= 0x90 && d <= 0x95) { //dacstream command
if (!Loader_RequestedDacStreamFindStart) {
DacStream_BeginFinding(&Loader_VgmDataBlocks, Loader_VgmDataBlockIndex, Loader_VgmFilePos-1);
DacStream_BeginFinding((VgmDataBlockStruct_t *)&Loader_VgmDataBlocks, Loader_VgmDataBlockIndex, Loader_VgmFilePos-1);
Loader_RequestedDacStreamFindStart = true;
}
MegaStream_Send(&Driver_CommandStream, &d, 1); //command
......@@ -309,4 +335,4 @@ bool Loader_Stop() {
ESP_LOGE(TAG, "Loader stop request timeout !!");
return false;
}
}
\ No newline at end of file
}
......@@ -181,7 +181,7 @@ void checkcore() {
LcdDma_AltMode = true;
LcdDma_Mutex_Give();
ESP_LOGI(TAG, "looking for core...");
esp_partition_t *corepart;
const esp_partition_t *corepart;
corepart = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_COREDUMP, NULL);
if (corepart) {
uint8_t *core;
......@@ -237,7 +237,7 @@ void checkcore() {
void app_main(void)
{
uint8_t r = rtc_get_reset_reason(0);
//uint8_t r = rtc_get_reset_reason(0);
#ifdef FWUPDATE
ESP_LOGI(TAG, "MegaGRRL OS Updater");
......@@ -499,7 +499,7 @@ void app_main(void)
LcdDma_Mutex_Take(pdMS_TO_TICKS(1000));
lv_ta_add_text(textarea, "Locating OS partition\n");
LcdDma_Mutex_Give();
esp_partition_t *partition;
const esp_partition_t *partition;
partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL);
uint8_t *app;
spi_flash_mmap_handle_t mmaphandle;
......@@ -752,4 +752,4 @@ void app_main(void)
LcdDma_Mutex_Give();
#endif
}
\ No newline at end of file
}
......@@ -296,7 +296,7 @@ static tinfl_status Player_Unvgz(char *FilePath, bool ReplaceOriginalFile) {
}
bool Player_StartTrack(char *FilePath) {
char *OpenFilePath = FilePath;
const char *OpenFilePath = FilePath;
ESP_LOGI(TAG, "Checking file type of %s", FilePath);
FILE *test = fopen(FilePath, "r");
......@@ -593,4 +593,4 @@ bool Player_StopTrack() {
fclose(Driver_Opna_PcmUploadFile);
return true;
}
\ No newline at end of file
}
......@@ -36,7 +36,7 @@ void QueueLoadM3u(char *M3uPath, char *M3uFilename, uint32_t pos, bool CountComm
if (QueueM3uFile) fclose(QueueM3uFile);
QueueM3uFile = fopen(&QueueM3uFilename[0], "r");
while (!feof(QueueM3uFile)) {
uint32_t pos = ftell(QueueM3uFile); //might be faster to add up strlens rather than ftell?
pos = ftell(QueueM3uFile); //might be faster to add up strlens rather than ftell?
if (fgets(&QueueLine[0], 255, QueueM3uFile) == NULL) break;
if (QueueLine[0] != 0 && QueueLine[0] != 0x0d && QueueLine[0] != 0x0a) {
if ((QueueLine[0] == '#' && CountComments) || QueueLine[0] != '#') {
......@@ -100,11 +100,11 @@ bool QueuePrev() {
return true;
}
volatile char *qse_last_filename = NULL;
volatile const char *qse_last_filename = NULL;
void QueueSetupEntry(bool ReturnComments, bool ProcessShuffle) {
if (QueueSource == QUEUE_SOURCE_M3U) {
char *fn = (ProcessShuffle&&Queue_Shuffle)?cachefilename_shuf:cachefilename;
const char *fn = (ProcessShuffle&&Queue_Shuffle)?cachefilename_shuf:cachefilename;
if (cachefile && fn != qse_last_filename) {
fclose(cachefile);
cachefile = NULL;
......@@ -144,4 +144,4 @@ void QueueSetupEntry(bool ReturnComments, bool ProcessShuffle) {
}
//fclose(QueueM3uFile);
}
}
\ No newline at end of file
}
......@@ -14,7 +14,7 @@
#include "userled.h"
#include "options.h"
static const char* TAG = "Taskmgr";
//static const char* TAG = "Taskmgr";
TaskHandle_t Taskmgr_Handles[TASK_COUNT];
......@@ -36,4 +36,4 @@ void Taskmgr_CreateTasks() {
xTaskCreatePinnedToCore(OptionsMgr_Main, "OpnMgr", 2048, NULL, 15, &Taskmgr_Handles[TASK_OPTIONS], 0);
xTaskCreatePinnedToCore(Driver_Main, "Driver", 3072, NULL, configMAX_PRIORITIES-2, &Taskmgr_Handles[TASK_DRIVER], 1);
}
\ No newline at end of file
}
......@@ -24,6 +24,7 @@ typedef enum {
typedef enum {
SCROLLTYPE_PINGPONG,
SCROLLTYPE_CIRCULAR,
SCROLLTYPE_DOT,
SCROLLTYPE_COUNT,
} ScrollType_t;
......@@ -37,4 +38,4 @@ bool Ui_Setup();
void Ui_Main();
lv_label_long_mode_t Ui_GetScrollType();
#endif
\ No newline at end of file
#endif
......@@ -54,7 +54,7 @@ const char *about_text =
#include "about.h"
#include "softbar.h"
static const char* TAG = "Ui_About";
//static const char* TAG = "Ui_About";
int32_t about_map(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
......@@ -131,4 +131,4 @@ void Ui_About_Tick() {
lv_obj_set_pos(about_ta, 0, 250-y);
LcdDma_Mutex_Give();
}
\ No newline at end of file
}
......@@ -41,12 +41,13 @@ static IRAM_ATTR lv_obj_t *samplelabel1;
static IRAM_ATTR lv_obj_t *samplelabel2;
static bool fast = false;
static int comp(const TaskStatus_t *a, const TaskStatus_t *b) {
return strcmp(a->pcTaskName, b->pcTaskName);
static int comp(const void *a, const void *b) {
const TaskStatus_t *tsa = a, *tsb = b;
return strcmp(tsa->pcTaskName, tsb->pcTaskName);
}
static uint32_t map(uint32_t x, uint32_t in_min, uint32_t in_max, uint32_t out_min, uint32_t out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
static void draw() {
......@@ -76,7 +77,7 @@ static void draw() {
for (uint8_t i=0;i<DACSTREAM_PRE_COUNT;i++) {
lv_obj_set_style(ds[i], (i==DacStreamId)?&bar_style:&bar_style_idle);
lv_obj_set_size(ds[i], map(MegaStream_Used(&DacStreamEntries[i].Stream), 0, DACSTREAM_BUF_SIZE, 0, 240), 1);
lv_obj_set_size(ds[i], map(MegaStream_Used((MegaStreamContext_t *)&DacStreamEntries[i].Stream), 0, DACSTREAM_BUF_SIZE, 0, 240), 1);
}
LcdDma_Mutex_Give();
......@@ -90,7 +91,7 @@ static void drawtasks() {
uint32_t trt;
uxTaskGetSystemState(&taskstatus[0], TASK_COUNT+6, &trt);
qsort(taskstatus, TASK_COUNT+6, sizeof(TaskStatus_t), comp); //todo fix warning
qsort(taskstatus, TASK_COUNT+6, sizeof(TaskStatus_t), comp);
for (uint8_t i=0;i<TASK_COUNT+6;i++) {
uint8_t blacklisted = false;
for (uint8_t q=0;q<6;q++) {
......@@ -248,4 +249,4 @@ void Ui_Debug_Tick() {
drawtasks();
taskstimer = xthal_get_ccount();
}
}
\ No newline at end of file
}
......@@ -70,11 +70,12 @@ void Ui_FileBrowser_InvalidateDirEntry() {
direntry_invalidated = true;
}
static int comp(const uint32_t *offset1, const uint32_t *offset2) {
char *s1 = direntry_cache + *offset1;
char *s2 = direntry_cache + *offset2;
unsigned char t1 = direntry_cache[*offset1-1];
unsigned char t2 = direntry_cache[*offset2-1];
static int comp(const void *offset1, const void *offset2) {
const uint32_t *o1 = offset1, *o2 = offset2;
char *s1 = direntry_cache + *o1;
char *s2 = direntry_cache + *o2;
unsigned char t1 = direntry_cache[*o1-1];
unsigned char t2 = direntry_cache[*o2-1];
if (Ui_FileBrowser_DirsBeforeFiles) if (t1 != t2) return t2-t1; //cheezy, but should be fine
if (Ui_FileBrowser_SortDir == SORT_ASCENDING) {
return strcasecmp(s1, s2);
......@@ -83,10 +84,10 @@ static int comp(const uint32_t *offset1, const uint32_t *offset2) {