You've already forked TEF6686_ESP32
Changed initialize data to PROGMEM to save RAM
This commit is contained in:
@@ -128,9 +128,9 @@ void TEF6686::init(byte TEF) {
|
||||
if (bootstatus == 0) {
|
||||
Tuner_Patch(TEF);
|
||||
delay(50);
|
||||
if (digitalRead(15) == LOW) Tuner_Init9216(); else Tuner_Init4000();
|
||||
if (digitalRead(15) == LOW) Tuner_Init(tuner_init_tab9216); else Tuner_Init(tuner_init_tab4000);
|
||||
power(1);
|
||||
Tuner_Init();
|
||||
Tuner_Init(tuner_init_tab);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
#include "Tuner_Drv_Lithio.h"
|
||||
#include "Tuner_Interface.h"
|
||||
|
||||
extern const unsigned char tuner_init_tab[] PROGMEM;
|
||||
extern const unsigned char tuner_init_tab9216[] PROGMEM;
|
||||
extern const unsigned char tuner_init_tab4000[] PROGMEM;
|
||||
|
||||
enum RDS_GROUPS {
|
||||
RDS_GROUP_0A, RDS_GROUP_0B, RDS_GROUP_1A, RDS_GROUP_1B, RDS_GROUP_2A, RDS_GROUP_2B, RDS_GROUP_3A, RDS_GROUP_3B,
|
||||
RDS_GROUP_4A, RDS_GROUP_4B, RDS_GROUP_5A, RDS_GROUP_5B, RDS_GROUP_6A, RDS_GROUP_6B, RDS_GROUP_7A, RDS_GROUP_7B,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "Tuner_Patch_Lithio_V205_p512.h"
|
||||
#include <Wire.h>
|
||||
|
||||
static const unsigned char tuner_init_tab[] = {
|
||||
const unsigned char tuner_init_tab[] PROGMEM = {
|
||||
7, 0x20, 0x0B, 0x01, 0x03, 0x98, 0x00, 0x00,
|
||||
5, 0x20, 0x14, 0x01, 0x00, 0x00,
|
||||
5, 0x20, 0x16, 0x01, 0x00, 0x00,
|
||||
@@ -34,7 +34,7 @@ static const unsigned char tuner_init_tab[] = {
|
||||
13, 0x30, 0x16, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x12, 0xc0
|
||||
};
|
||||
|
||||
static const unsigned char tuner_init_tab4000[] = {
|
||||
const unsigned char tuner_init_tab4000[] PROGMEM = {
|
||||
3, 0x14, 0x00, 0x01,
|
||||
2, 0xff, 50,
|
||||
9, 0x40, 0x04, 0x01, 0x00, 0x3D, 0x09, 0x00, 0x00, 0x00,
|
||||
@@ -42,7 +42,7 @@ static const unsigned char tuner_init_tab4000[] = {
|
||||
2, 0xff, 100,
|
||||
};
|
||||
|
||||
static const unsigned char tuner_init_tab9216[] = {
|
||||
const unsigned char tuner_init_tab9216[] PROGMEM = {
|
||||
3, 0x14, 0x00, 0x01,
|
||||
2, 0xff, 50,
|
||||
9, 0x40, 0x04, 0x01, 0x00, 0x8C, 0xA0, 0x00, 0x00, 0x00,
|
||||
@@ -67,26 +67,23 @@ bool Tuner_ReadBuffer(unsigned char *buf, uint16_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) {
|
||||
static void Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) {
|
||||
unsigned char buf[24 + 1];
|
||||
uint16_t i, len;
|
||||
uint16_t r;
|
||||
buf[0] = 0x1b;
|
||||
|
||||
while (size)
|
||||
{
|
||||
while (size) {
|
||||
len = (size > 24) ? 24 : size;
|
||||
size -= len;
|
||||
|
||||
for (i = 0; i < len; i++) buf[1 + i] = pLutBytes[i];
|
||||
for (i = 0; i < len; i++) buf[1 + i] = pgm_read_byte(&pLutBytes[i]);
|
||||
pLutBytes += len;
|
||||
|
||||
if (1 != (r = Tuner_WriteBuffer(buf, len + 1))) break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
bool Tuner_Table_Write(const unsigned char *tab) {
|
||||
if (tab[1] == 0xff) {
|
||||
delay(tab[2]);
|
||||
@@ -157,32 +154,11 @@ void Tuner_I2C_Init() {
|
||||
delay(5);
|
||||
}
|
||||
|
||||
bool Tuner_Init(void) {
|
||||
void Tuner_Init(const unsigned char *table) {
|
||||
uint16_t r;
|
||||
const unsigned char *p = tuner_init_tab;
|
||||
const unsigned char *p = table;
|
||||
|
||||
for (uint16_t i = 0; i < sizeof(tuner_init_tab); i += (p[i] + 1)) {
|
||||
for (uint16_t i = 0; i < sizeof(tuner_init_tab); i += (pgm_read_byte(p + i) + 1)) {
|
||||
if (1 != (r = Tuner_Table_Write(p + i))) break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
bool Tuner_Init4000(void) {
|
||||
uint16_t r;
|
||||
const unsigned char *p = tuner_init_tab4000;
|
||||
|
||||
for (uint16_t i = 0; i < sizeof(tuner_init_tab4000); i += (p[i] + 1)) {
|
||||
if (1 != (r = Tuner_Table_Write(p + i))) break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
bool Tuner_Init9216(void) {
|
||||
uint16_t r;
|
||||
const unsigned char *p = tuner_init_tab9216;
|
||||
|
||||
for (uint16_t i = 0; i < sizeof(tuner_init_tab9216); i += (p[i] + 1)) {
|
||||
if (1 != (r = Tuner_Table_Write(p + i))) break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
void Tuner_I2C_Init();
|
||||
void Tuner_Patch(byte TEF);
|
||||
bool Tuner_Init();
|
||||
bool Tuner_Init4000();
|
||||
bool Tuner_Init9216();
|
||||
void Tuner_Init(const unsigned char *table);
|
||||
bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len);
|
||||
bool Tuner_ReadBuffer(unsigned char *buf, uint16_t len);
|
||||
bool Tuner_Table_Write(const unsigned char *tab);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extern const size_t PatchSize102;
|
||||
extern const unsigned char *pPatchBytes102;
|
||||
static const unsigned char PatchByteValues102[] = {
|
||||
static const unsigned char PatchByteValues102[] PROGMEM = {
|
||||
0xF0, 0x00, 0x38, 0x3B, 0xD0, 0x80, 0xF0, 0x00, 0x38, 0x43, 0xD0, 0x80, 0x43, 0xB2, 0x38, 0x46, 0xD0, 0x80, 0xF0, 0x00, 0x70, 0x00, 0xC2, 0xF7,
|
||||
0xF0, 0x00, 0x38, 0x77, 0xD0, 0x80, 0xF0, 0x00, 0x38, 0x7B, 0xDF, 0x80, 0x80, 0xFC, 0x39, 0x0E, 0xD0, 0x80, 0xC2, 0x38, 0x20, 0x11, 0x40, 0xB7,
|
||||
0x9F, 0xA7, 0x39, 0x13, 0xD2, 0x80, 0x9F, 0xA7, 0x39, 0x1D, 0xD2, 0x80, 0xF0, 0x00, 0x39, 0x24, 0xD0, 0x80, 0xF0, 0x00, 0x39, 0x27, 0xD0, 0x80,
|
||||
@@ -263,7 +263,7 @@ const unsigned char * pPatchBytes102 = &PatchByteValues102[0];
|
||||
|
||||
extern const size_t LutSize102;
|
||||
extern const unsigned char * pLutBytes102;
|
||||
static unsigned char LutByteValues102[] = {
|
||||
static const unsigned char LutByteValues102[] PROGMEM = {
|
||||
0x40, 0x13, 0x40, 0x2F, 0x41, 0x68, 0x41, 0xC1,
|
||||
0x42, 0x14, 0x42, 0xA6, 0x44, 0xDE, 0x44, 0xE9,
|
||||
0x45, 0xFB, 0x46, 0x11, 0x47, 0xC5, 0x47, 0xFC,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extern const size_t PatchSize205;
|
||||
extern const unsigned char *pPatchBytes205;
|
||||
static const unsigned char PatchByteValues205[] = {
|
||||
static const unsigned char PatchByteValues205[] PROGMEM = {
|
||||
0xF0, 0x00, 0x60, 0x40, 0xD0, 0x80, 0x20, 0x87, 0x60, 0x4C, 0xD0, 0x80, 0x90, 0x00, 0x60, 0x4E, 0xD0, 0x80, 0x22, 0x02, 0x00, 0x55, 0x60, 0x04,
|
||||
0xF0, 0x00, 0x60, 0x65, 0xDF, 0x80, 0xF0, 0x00, 0x05, 0xBA, 0x60, 0x0E, 0x20, 0x90, 0x60, 0x9B, 0xD0, 0x80, 0x31, 0x40, 0x60, 0x9F, 0xD0, 0x80,
|
||||
0x9E, 0xB9, 0x60, 0xAD, 0xD0, 0x80, 0xF0, 0x00, 0x60, 0xAF, 0xD0, 0x80, 0x20, 0x15, 0x60, 0xB3, 0xD2, 0x80, 0xF0, 0x00, 0x60, 0xCE, 0xD0, 0x80,
|
||||
@@ -248,7 +248,7 @@ const unsigned char * pPatchBytes205 = &PatchByteValues205[0];
|
||||
|
||||
extern const size_t LutSize205;
|
||||
extern const unsigned char * pLutBytes205;
|
||||
static unsigned char LutByteValues205[] = {
|
||||
static const unsigned char LutByteValues205[] PROGMEM = {
|
||||
0x80, 0x17, 0x80, 0x45, 0x80, 0x96, 0x81, 0x5B, 0x82, 0xD6, 0x83, 0x76, 0x88, 0x0B, 0x88, 0x10, 0x88, 0xDB, 0x89, 0x48, 0x89, 0xE9, 0x8B, 0x0A,
|
||||
0x8B, 0x12, 0x8B, 0x13, 0x8B, 0x21, 0x8B, 0x26, 0x8C, 0x6F, 0x8F, 0x91, 0x8F, 0xF6, 0x94, 0xD0, 0x95, 0x20, 0x95, 0x33, 0x95, 0x6F, 0x95, 0xA8,
|
||||
0x95, 0xAC, 0x95, 0xC3, 0x95, 0xE1, 0x97, 0xC9, 0x97, 0xF6, 0x98, 0x8D, 0x99, 0x00, 0x9A, 0x00, 0x9E, 0x73, 0xA0, 0x12, 0xA1, 0x03, 0xA1, 0x68,
|
||||
|
||||
Reference in New Issue
Block a user