[ARM] Support of s16le wav files
[ACT] New GVARS menu started [X9D] Volume control added
This commit is contained in:
+3
-3
@@ -474,7 +474,7 @@ ifeq ($(PCB), ACT)
|
||||
EXTRABOARDSRC += x9d/lcd_driver.cpp
|
||||
SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c
|
||||
EEPROMSRC = eeprom_avr.cpp # TODO later eeprom_conversions.cpp
|
||||
CPPSRC += x9d/eeprom_driver.cpp x9d/pulses_driver.cpp act/keys_driver.cpp act/audio_driver.cpp
|
||||
CPPSRC += x9d/pulses_driver.cpp act/keys_driver.cpp act/audio_driver.cpp
|
||||
CPPSRC += audio_arm.cpp
|
||||
PULSESSRC = pulses_arm.cpp
|
||||
CPPSRC += monitors_views.cpp
|
||||
@@ -487,12 +487,12 @@ ifeq ($(PCB), X9D)
|
||||
EXTRAINCDIRS += CoOS/kernel CoOS/portable
|
||||
EXTRAINCDIRS += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include
|
||||
BOARDSRC = x9d/board_x9d.cpp
|
||||
EXTRABOARDSRC += x9d/lcd_driver.cpp x9d/aspi.cpp x9d/i2c_ee.c
|
||||
EXTRABOARDSRC += x9d/lcd_driver.cpp x9d/aspi.cpp x9d/i2c.c
|
||||
SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c
|
||||
EEPROMSRC = eeprom_avr.cpp # TODO later eeprom_conversions.cpp
|
||||
PULSESSRC = pulses_arm.cpp
|
||||
CPPSRC += audio_arm.cpp
|
||||
CPPSRC += x9d/pwr_driver.cpp x9d/eeprom_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/adc_driver.cpp x9d/trainer_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp
|
||||
CPPSRC += x9d/pwr_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/adc_driver.cpp x9d/trainer_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp
|
||||
CPPSRC += bmp.cpp monitors_views.cpp
|
||||
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
|
||||
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
||||
|
||||
@@ -67,7 +67,6 @@ extern void sdInit();
|
||||
|
||||
void usbMassStorage();
|
||||
|
||||
void setVolume( register uint8_t volume );
|
||||
#define JACK_PPM_OUT()
|
||||
#define JACK_PPM_IN()
|
||||
|
||||
|
||||
+26
-11
@@ -282,11 +282,6 @@ void audioTimerHandle(void)
|
||||
CoSetFlag(audioFlag);
|
||||
}
|
||||
|
||||
// TODO Should be here!
|
||||
extern uint16_t Sine_values[];
|
||||
|
||||
#define WAV_HEADER_SIZE 44
|
||||
|
||||
#define CODEC_ID_PCM_S16LE 1
|
||||
#define CODEC_ID_PCM_ALAW 6
|
||||
#define CODEC_ID_PCM_MULAW 7
|
||||
@@ -316,6 +311,9 @@ uint16_t * nextAudioData = NULL;
|
||||
uint16_t nextAudioSize = 0;
|
||||
|
||||
#if defined(SDCARD) && !defined(SIMU)
|
||||
|
||||
#define RIFF_CHUNK_SIZE 12
|
||||
|
||||
void AudioQueue::sdWakeup(AudioContext & context)
|
||||
{
|
||||
if (!nextAudioData) {
|
||||
@@ -326,12 +324,25 @@ void AudioQueue::sdWakeup(AudioContext & context)
|
||||
result = f_open(&context.wavFile, fragment.file, FA_OPEN_EXISTING | FA_READ);
|
||||
fragment.file[1] = 0;
|
||||
if (result == FR_OK) {
|
||||
result = f_read(&context.wavFile, (uint8_t *)wavSamplesBuffer, WAV_HEADER_SIZE, &read);
|
||||
if (result == FR_OK && read == WAV_HEADER_SIZE && !memcmp(wavSamplesBuffer, "RIFF", 4)) {
|
||||
context.pcmCodec = wavSamplesBuffer[10];
|
||||
context.pcmFreq = wavSamplesBuffer[12];
|
||||
if (context.pcmCodec != CODEC_ID_PCM_S16LE) {
|
||||
result = f_read(&context.wavFile, (uint8_t *)wavSamplesBuffer, 12, &read);
|
||||
result = f_read(&context.wavFile, (uint8_t *)wavSamplesBuffer, RIFF_CHUNK_SIZE+8, &read);
|
||||
if (result == FR_OK && read == RIFF_CHUNK_SIZE+8 && !memcmp(wavSamplesBuffer, "RIFF", 4) && !memcmp(wavSamplesBuffer+4/*short*/, "WAVEfmt ", 8)) {
|
||||
uint32_t size = *((uint32_t *)(wavSamplesBuffer+8/*short*/));
|
||||
result = (size < 256 ? f_read(&context.wavFile, (uint8_t *)wavSamplesBuffer, size+8, &read) : FR_DENIED);
|
||||
if (result == FR_OK && read == size+8) {
|
||||
context.pcmCodec = wavSamplesBuffer[0];
|
||||
context.pcmFreq = wavSamplesBuffer[2];
|
||||
uint32_t *wavSamplesPtr = (uint32_t *)(wavSamplesBuffer + size/2);
|
||||
uint32_t size = wavSamplesPtr[1];
|
||||
while (result == FR_OK && memcmp(wavSamplesPtr, "data", 4) != 0) {
|
||||
result = (size < 256 ? f_read(&context.wavFile, (uint8_t *)wavSamplesBuffer, size+8, &read) : FR_DENIED);
|
||||
if (read != size+8) result = FR_DENIED;
|
||||
wavSamplesPtr = (uint32_t *)(wavSamplesBuffer + size/2);
|
||||
size = wavSamplesPtr[1];
|
||||
}
|
||||
context.wavSize = size;
|
||||
}
|
||||
else {
|
||||
result = FR_DENIED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -356,6 +367,10 @@ void AudioQueue::sdWakeup(AudioContext & context)
|
||||
state = AUDIO_RESUMING;
|
||||
}
|
||||
else {
|
||||
if (read > context.wavSize)
|
||||
read = context.wavSize;
|
||||
context.wavSize -= read;
|
||||
|
||||
if (read != bufsize) {
|
||||
memset(&fragment, 0, sizeof(fragment));
|
||||
f_close(&context.wavFile);
|
||||
|
||||
@@ -77,6 +77,7 @@ class AudioContext {
|
||||
#endif
|
||||
uint8_t pcmCodec;
|
||||
uint32_t pcmFreq;
|
||||
uint32_t wavSize;
|
||||
};
|
||||
|
||||
class AudioQueue {
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@ void putEvent(uint8_t evt)
|
||||
uint8_t getEvent(bool trim)
|
||||
{
|
||||
uint8_t evt = s_evt;
|
||||
int8_t k = (s_evt & EVT_KEY_MASK) - TRM_BASE;
|
||||
int8_t k = EVT_KEY_MASK(s_evt) - TRM_BASE;
|
||||
bool trim_evt = (k>=0 && k<8);
|
||||
|
||||
if (trim == trim_evt) {
|
||||
@@ -137,13 +137,13 @@ void Key::input(bool val, EnumKeys enuk)
|
||||
|
||||
void pauseEvents(uint8_t event)
|
||||
{
|
||||
event = event & EVT_KEY_MASK;
|
||||
event = EVT_KEY_MASK(event);
|
||||
if (event < (int)DIM(keys)) keys[event].pauseEvents();
|
||||
}
|
||||
|
||||
void killEvents(uint8_t event)
|
||||
{
|
||||
event = event & EVT_KEY_MASK;
|
||||
event = EVT_KEY_MASK(event);
|
||||
if (event < (int)DIM(keys)) keys[event].killEvents();
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -198,9 +198,9 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
||||
else if (flags & TINSIZE) {
|
||||
q = &font_3x5[((uint16_t)c-0x2D)*3+2];
|
||||
uint8_t ym8 = (y % 8);
|
||||
p += 2;
|
||||
for (int8_t i=2; i>=0; i--) {
|
||||
uint8_t b = pgm_read_byte(q--);
|
||||
p += 3;
|
||||
for (int8_t i=3; i>=0; i--) {
|
||||
uint8_t b = (i!=3 ? pgm_read_byte(q--) : 0);
|
||||
if (inv) b = ~b & 0x3f;
|
||||
if (p<DISPLAY_END) {
|
||||
LCD_BYTE_FILTER(p, ~(0x3f << ym8), b << ym8);
|
||||
@@ -393,6 +393,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, int16_t val, LcdFlags flags, uint8_t
|
||||
}
|
||||
else if (tinsize) {
|
||||
fw -= 1;
|
||||
x += 1;
|
||||
}
|
||||
else {
|
||||
if (flags & LEFT) {
|
||||
|
||||
+1
-1
@@ -231,7 +231,7 @@ void displayVoltage()
|
||||
else {
|
||||
LcdFlags att = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK|INVERS : 0) | BIGSIZE;
|
||||
putsVBat(VBATT_X-1, VBATT_Y, att|NO_UNIT);
|
||||
#if LCD >= 212
|
||||
#if LCD_W >= 212
|
||||
lcd_putcAtt(VBATTUNIT_X, VBATTUNIT_Y, 'v', MIDSIZE);
|
||||
#else
|
||||
lcd_putc(VBATT_X, VBATTUNIT_Y, 'V');
|
||||
|
||||
+4
-2
@@ -91,7 +91,7 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
|
||||
|
||||
#if defined(DBLKEYS)
|
||||
uint8_t in = KEYS_PRESSED();
|
||||
if (event & EVT_KEY_MASK) {
|
||||
if (EVT_KEY_MASK(event)) {
|
||||
bool dblkey = true;
|
||||
if (DBLKEYS_PRESSED_RGT_LFT(in))
|
||||
newval = -val;
|
||||
@@ -183,6 +183,7 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
|
||||
return newval;
|
||||
}
|
||||
|
||||
#if defined(CPUM64)
|
||||
int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max)
|
||||
{
|
||||
return checkIncDec(event,i_val,i_min,i_max,EE_MODEL);
|
||||
@@ -192,6 +193,7 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max)
|
||||
{
|
||||
return checkIncDec(event,i_val,i_min,i_max,EE_GENERAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, maxrow_t maxrow)
|
||||
{
|
||||
@@ -222,7 +224,7 @@ void check_rotary_encoder(uint8_t & event)
|
||||
}
|
||||
|
||||
// TODO remove later...
|
||||
uint8_t key = event & EVT_KEY_MASK;
|
||||
uint8_t key = EVT_KEY_MASK(event);
|
||||
if (key==KEY_MOVE_UP || key==KEY_MOVE_DOWN)
|
||||
event = 0;
|
||||
}
|
||||
|
||||
+12
-6
@@ -110,12 +110,12 @@ extern int16_t p1valdiff;
|
||||
#define IS_RE_NAVIGATION_ENABLE() true
|
||||
#define NAVIGATION_RE_IDX() 0
|
||||
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (event==type(KEY_ENTER))
|
||||
#define IS_RE_NAVIGATION_EVT(event) ((event&EVT_KEY_MASK)==KEY_ENTER)
|
||||
#define IS_RE_NAVIGATION_EVT(event) (EVT_KEY_MASK(event)==KEY_ENTER)
|
||||
#elif defined(ROTARY_ENCODERS)
|
||||
#define NAVIGATION_RE_IDX() (g_eeGeneral.reNavigation - 1)
|
||||
#define IS_RE_NAVIGATION_ENABLE() g_eeGeneral.reNavigation
|
||||
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (g_eeGeneral.reNavigation && event==type(BTN_REa + g_eeGeneral.reNavigation - 1))
|
||||
#define IS_RE_NAVIGATION_EVT(event) (g_eeGeneral.reNavigation && (event&EVT_KEY_MASK)==(BTN_REa + g_eeGeneral.reNavigation - 1))
|
||||
#define IS_RE_NAVIGATION_EVT(event) (g_eeGeneral.reNavigation && EVT_KEY_MASK(event)==(BTN_REa + g_eeGeneral.reNavigation - 1))
|
||||
#else
|
||||
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (0)
|
||||
#define IS_RE_NAVIGATION_EVT(event) (0)
|
||||
@@ -130,8 +130,14 @@ extern int8_t s_editMode; // global editmode
|
||||
#define NO_INCDEC_MARKS 0x04
|
||||
#define INCDEC_SWITCH 0x08
|
||||
int16_t checkIncDec(uint8_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags);
|
||||
|
||||
#if defined(CPUM64)
|
||||
int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
||||
int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
||||
#else
|
||||
#define checkIncDecModel(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_MODEL)
|
||||
#define checkIncDecGen(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_GENERAL)
|
||||
#endif
|
||||
|
||||
#define CHECK_INCDEC_MODELVAR(event, var, min, max) \
|
||||
var = checkIncDecModel(event,var,min,max)
|
||||
@@ -259,12 +265,12 @@ void menuChannelsMonitor(uint8_t event);
|
||||
#define LABEL(...) (uint8_t)-1
|
||||
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
#define CURSOR_MOVED_LEFT(event) ((event & EVT_KEY_MASK) == KEY_LEFT || lastCursorMove < 0)
|
||||
#define CURSOR_MOVED_RIGHT(event) ((event & EVT_KEY_MASK) == KEY_RIGHT || lastCursorMove > 0)
|
||||
#define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_LEFT || lastCursorMove < 0)
|
||||
#define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_RIGHT || lastCursorMove > 0)
|
||||
#define REPEAT_LAST_CURSOR_MOVE() if (lastCursorMove) lastCursorMove *= 2; else m_posHorz = 0
|
||||
#else
|
||||
#define CURSOR_MOVED_LEFT(event) ((event & EVT_KEY_MASK) == KEY_LEFT)
|
||||
#define CURSOR_MOVED_RIGHT(event) ((event & EVT_KEY_MASK) == KEY_RIGHT)
|
||||
#define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_LEFT)
|
||||
#define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_RIGHT)
|
||||
#define REPEAT_LAST_CURSOR_MOVE() m_posHorz = 0;
|
||||
#endif
|
||||
|
||||
|
||||
+88
-12
@@ -47,6 +47,9 @@ enum EnumTabModel {
|
||||
e_MixAll,
|
||||
e_Limits,
|
||||
IF_CURVES(e_CurvesAll)
|
||||
#if LCD_W >= 260
|
||||
IF_GVARS(e_GVars)
|
||||
#endif
|
||||
e_CustomSwitches,
|
||||
e_CustomFunctions,
|
||||
IF_FRSKY(e_Telemetry)
|
||||
@@ -55,24 +58,17 @@ enum EnumTabModel {
|
||||
|
||||
void menuModelSelect(uint8_t event);
|
||||
void menuModelSetup(uint8_t event);
|
||||
#ifdef HELI
|
||||
void menuModelHeli(uint8_t event);
|
||||
#endif
|
||||
#ifdef FLIGHT_PHASES
|
||||
void menuModelPhasesAll(uint8_t event);
|
||||
#endif
|
||||
void menuModelExposAll(uint8_t event);
|
||||
void menuModelMixAll(uint8_t event);
|
||||
void menuModelLimits(uint8_t event);
|
||||
void menuModelCurvesAll(uint8_t event);
|
||||
void menuModelGVars(uint8_t event);
|
||||
void menuModelCustomSwitches(uint8_t event);
|
||||
void menuModelCustomFunctions(uint8_t event);
|
||||
#ifdef FRSKY
|
||||
void menuModelTelemetry(uint8_t event);
|
||||
#endif
|
||||
#ifdef TEMPLATES
|
||||
void menuModelTemplates(uint8_t event);
|
||||
#endif
|
||||
void menuModelExpoOne(uint8_t event);
|
||||
|
||||
const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
|
||||
@@ -84,6 +80,9 @@ const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
|
||||
menuModelMixAll,
|
||||
menuModelLimits,
|
||||
IF_CURVES(menuModelCurvesAll)
|
||||
#if LCD_W >= 260
|
||||
IF_GVARS(menuModelGVars)
|
||||
#endif
|
||||
menuModelCustomSwitches,
|
||||
menuModelCustomFunctions,
|
||||
IF_FRSKY(menuModelTelemetry)
|
||||
@@ -579,23 +578,39 @@ void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, boo
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
#if defined(PCBX9D) || defined(PCBACT)
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
if (next<size-1) {
|
||||
next++;
|
||||
}
|
||||
else {
|
||||
s_editMode = 0;
|
||||
next = 0;
|
||||
}
|
||||
break;
|
||||
#else
|
||||
case EVT_KEY_BREAK(KEY_LEFT):
|
||||
if (next>0) next--;
|
||||
break;
|
||||
case EVT_KEY_BREAK(KEY_RIGHT):
|
||||
if (next<size-1) next++;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
case EVT_KEY_LONG(BTN_REa):
|
||||
case EVT_KEY_LONG(BTN_REb):
|
||||
if (!navigationRotaryEncoder(event))
|
||||
break;
|
||||
// no break
|
||||
#endif
|
||||
#if defined(PCBX9D) || defined(PCBACT)
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
#endif
|
||||
if (v==0) {
|
||||
s_editMode = 0;
|
||||
next = 0;
|
||||
killEvents(event);
|
||||
break;
|
||||
}
|
||||
@@ -1137,12 +1152,12 @@ void menuModelPhaseOne(uint8_t event)
|
||||
case ITEM_MODEL_PHASE_FADE_IN:
|
||||
phase->fadeIn = editDelay(y, event, attr, STR_FADEIN, phase->fadeIn);
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_PHASE_FADE_OUT:
|
||||
phase->fadeOut = editDelay(y, event, attr, STR_FADEOUT, phase->fadeOut);
|
||||
break;
|
||||
|
||||
#if defined(GVARS) && !defined(CPUM64)
|
||||
|
||||
case ITEM_MODEL_PHASE_GVARS_LABEL:
|
||||
lcd_putsLeft(y, STR_GLOBAL_VARS);
|
||||
break;
|
||||
@@ -1151,10 +1166,15 @@ void menuModelPhaseOne(uint8_t event)
|
||||
{
|
||||
uint8_t idx = i-ITEM_MODEL_PHASE_GV1;
|
||||
|
||||
if (editingName)
|
||||
if (editingName) {
|
||||
#if defined(PCBX9D) || defined(PCBACT)
|
||||
if (attr) s_editMode = 1;
|
||||
#endif
|
||||
editName(4*FW, y, g_model.gvarsNames[idx], sizeof(gvar_name_t), event, attr, m_posHorz);
|
||||
else
|
||||
}
|
||||
else {
|
||||
lcd_putsnAtt(4*FW, y, g_model.gvarsNames[idx], sizeof(gvar_name_t), ZCHAR|(m_posHorz==0 ? attr : 0));
|
||||
}
|
||||
|
||||
lcd_putsLeft(y, PSTR(" "));
|
||||
putsStrIdx(INDENT_WIDTH, y, STR_GV, idx+1);
|
||||
@@ -1180,7 +1200,7 @@ void menuModelPhaseOne(uint8_t event)
|
||||
uint8_t p = getGVarFlightPhase(s_currIdx, idx);
|
||||
lcd_outdezAtt(21*FW, y, GVAR_VALUE(idx, p), !editingName && m_posHorz==2 ? attr : 0);
|
||||
if (attr && !editingName && m_posHorz==2 && ((editMode>0) || p1valdiff))
|
||||
GVAR_VALUE(idx, p) = checkIncDec(event, GVAR_VALUE(idx, p), -1024, +1024, EE_MODEL);
|
||||
GVAR_VALUE(idx, p) = checkIncDec(event, GVAR_VALUE(idx, p), -GVAR_MAX, GVAR_MAX, EE_MODEL);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -2558,6 +2578,62 @@ void menuModelCurvesAll(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LCD_W >= 260 && defined(GVARS)
|
||||
void menuModelGVars(uint8_t event)
|
||||
{
|
||||
MENU(PSTR("GLOBAL VARIABLES"), menuTabModel, e_GVars, 1+MAX_GVARS, {0, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES, MAX_PHASES});
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
static bool editingName = false;
|
||||
if (editingName && s_editMode <= 0) editingName = false;
|
||||
if (!editingName && s_editMode > 0 && m_posHorz == 0) editingName = true;
|
||||
|
||||
for (uint8_t i=0; i<MAX_GVARS; i++) {
|
||||
uint8_t y = 1 + 2*FH + i*FH;
|
||||
|
||||
for (uint8_t j=0; j<1+MAX_PHASES; j++) {
|
||||
uint8_t attr = ((sub==i && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||
switch(j)
|
||||
{
|
||||
case 0:
|
||||
if (editingName && sub==i)
|
||||
editName(4*FW-3, y, g_model.gvarsNames[i], sizeof(gvar_name_t), event, attr, m_posHorz);
|
||||
else
|
||||
lcd_putsnAtt(4*FW-3, y, g_model.gvarsNames[i], sizeof(gvar_name_t), ZCHAR|(m_posHorz==0 ? attr : 0));
|
||||
// lcd_putsLeft(y, PSTR(" "));
|
||||
putsStrIdx(0, y, STR_GV, i+1);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
PhaseData *phase = &g_model.phaseData[j-1];
|
||||
int16_t v = phase->gvars[i];
|
||||
xcoord_t x = 14*FW + (j-1)*(2+4*FWNUM) - 1;
|
||||
int16_t vmin, vmax;
|
||||
if (v > GVAR_MAX) {
|
||||
uint8_t p = v - GVAR_MAX - 1;
|
||||
if (p >= s_currIdx) p++;
|
||||
putsFlightPhase(x, y, p+1, !editingName ? attr : 0);
|
||||
vmin = GVAR_MAX+1; vmax = GVAR_MAX+MAX_PHASES;
|
||||
}
|
||||
else {
|
||||
if (abs(v) >= 1000)
|
||||
lcd_outdezAtt(x, y+1, v, (editingName ? 0 : attr) | TINSIZE);
|
||||
else
|
||||
lcd_outdezAtt(x, y, v, (editingName ? 0 : attr));
|
||||
vmin = -GVAR_MAX; vmax = GVAR_MAX;
|
||||
}
|
||||
if (attr && !editingName && ((s_editMode>0) || p1valdiff)) {
|
||||
phase->gvars[i] = checkIncDec(event, v, vmin, vmax, EE_MODEL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
enum CustomSwitchFields {
|
||||
CSW_FIELD_FUNCTION,
|
||||
|
||||
+11
-9
@@ -1434,12 +1434,12 @@ void checkTrims()
|
||||
{
|
||||
uint8_t event = getEvent(true);
|
||||
if (event && !IS_KEY_BREAK(event)) {
|
||||
int8_t k = (event & EVT_KEY_MASK) - TRM_BASE;
|
||||
int8_t k = EVT_KEY_MASK(event) - TRM_BASE;
|
||||
int8_t s = g_model.trimInc;
|
||||
#else
|
||||
uint8_t checkTrim(uint8_t event)
|
||||
{
|
||||
int8_t k = (event & EVT_KEY_MASK) - TRM_BASE;
|
||||
int8_t k = EVT_KEY_MASK(event) - TRM_BASE;
|
||||
int8_t s = g_model.trimInc;
|
||||
if (k>=0 && k<8 && !IS_KEY_BREAK(event)) {
|
||||
#endif
|
||||
@@ -1992,7 +1992,7 @@ PLAY_FUNCTION(playValue, uint8_t idx)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
static uint8_t currentSpeakerVolume = 255;
|
||||
uint8_t currentSpeakerVolume = 255;
|
||||
uint8_t requiredSpeakerVolume;
|
||||
uint8_t fnSwitchDuration[NUM_FSW] = { 0 };
|
||||
#define FSW_PRESSLONG_DURATION 100
|
||||
@@ -2873,13 +2873,8 @@ void doMixerCalculations()
|
||||
#if defined(DSM2)
|
||||
if (s_rangecheck_mode) AUDIO_PLAY(AU_FRSKY_CHEEP);
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
if (currentSpeakerVolume != requiredSpeakerVolume) {
|
||||
setVolume(requiredSpeakerVolume);
|
||||
currentSpeakerVolume = requiredSpeakerVolume;
|
||||
}
|
||||
|
||||
#if defined(CPUARM)
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
@@ -2919,6 +2914,13 @@ void perMain()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
if (currentSpeakerVolume != requiredSpeakerVolume) {
|
||||
currentSpeakerVolume = requiredSpeakerVolume;
|
||||
setVolume(currentSpeakerVolume);
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO merge these 2 branches
|
||||
#if defined(PCBSKY9X)
|
||||
if (Eeprom32_process_state != E32_IDLE)
|
||||
|
||||
+2
-2
@@ -769,7 +769,7 @@ enum CswFunctions {
|
||||
#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG)
|
||||
#define EVT_ENTRY (0xff - _MSK_KEY_REPT)
|
||||
#define EVT_ENTRY_UP (0xfe - _MSK_KEY_REPT)
|
||||
#define EVT_KEY_MASK (0x0f)
|
||||
#define EVT_KEY_MASK(e) ((e) & 0x0f)
|
||||
|
||||
#define HEART_TIMER_PULSES 1
|
||||
#define HEART_TIMER10ms 2
|
||||
@@ -884,7 +884,7 @@ int16_t getRotaryEncoder(uint8_t idx);
|
||||
void incRotaryEncoder(uint8_t idx, int8_t inc);
|
||||
inline bool navigationRotaryEncoder(uint8_t event)
|
||||
{
|
||||
return g_eeGeneral.reNavigation == ((event & EVT_KEY_MASK) - BTN_REa + 1);
|
||||
return g_eeGeneral.reNavigation == (EVT_KEY_MASK(event) - BTN_REa + 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -382,10 +382,10 @@
|
||||
#define TR_PRESSANYKEYTOSKIP CENTER"Press any key to skip"
|
||||
#define TR_THROTTLENOTIDLE CENTER"Throttle not idle"
|
||||
#define TR_ALARMSDISABLED CENTER"Alarms Disabled"
|
||||
#define TR_PRESSANYKEY "\010Press any Key"
|
||||
#define TR_PRESSANYKEY TR("\010Press any Key",CENTER"Press any Key")
|
||||
#define TR_BADEEPROMDATA CENTER"Bad EEprom Data"
|
||||
#define TR_EEPROMFORMATTING "Formatting EEPROM"
|
||||
#define TR_EEPROMOVERFLOW "EEPROM overflow"
|
||||
#define TR_EEPROMFORMATTING CENTER"Formatting EEPROM"
|
||||
#define TR_EEPROMOVERFLOW CENTER"EEPROM overflow"
|
||||
#define TR_MENURADIOSETUP "RADIO SETUP"
|
||||
#define TR_MENUDATEANDTIME "DATE AND TIME"
|
||||
#define TR_MENUTRAINER "TRAINER"
|
||||
|
||||
@@ -71,8 +71,10 @@ inline uint16_t dacQueue(uint16_t *data, uint16_t size)
|
||||
return size;
|
||||
}
|
||||
|
||||
inline void setVolume( unsigned char volume )
|
||||
{
|
||||
}
|
||||
#if !defined(SIMU)
|
||||
#define setVolume(v) I2C_set_volume(v)
|
||||
#else
|
||||
#define setVolume(v)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+45
-35
@@ -47,7 +47,7 @@
|
||||
|
||||
#include "hal.h"
|
||||
#include "aspi.h"
|
||||
#include "i2c_ee.h"
|
||||
#include "i2c.h"
|
||||
#include "audio_driver.h"
|
||||
|
||||
#define PERI1_FREQUENCY 30000000
|
||||
@@ -65,7 +65,6 @@ void sdPoll10ms();
|
||||
|
||||
void usbMassStorage();
|
||||
|
||||
void setVolume( register uint8_t volume );
|
||||
#define JACK_PPM_OUT()
|
||||
#define JACK_PPM_IN()
|
||||
|
||||
@@ -85,50 +84,18 @@ void pwrOff();
|
||||
#define strcpy_P strcpy
|
||||
#define strcat_P strcat
|
||||
|
||||
extern uint32_t readKeys();
|
||||
#define KEYS_PRESSED() (~readKeys())
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & (0x20 + 0x40)) == (0x20 + 0x40))
|
||||
#define DBLKEYS_PRESSED_UP_DWN(i) ((in & (0x10 + 0x08)) == (0x10 + 0x08))
|
||||
#define DBLKEYS_PRESSED_RGT_UP(i) ((in & (0x20 + 0x10)) == (0x20 + 0x10))
|
||||
#define DBLKEYS_PRESSED_LFT_DWN(i) ((in & (0x40 + 0x08)) == (0x40 + 0x08))
|
||||
|
||||
extern uint16_t sessionTimer;
|
||||
|
||||
#define BOOTLOADER_REQUEST() (0/*usbPlugged()*/)
|
||||
|
||||
#define SLAVE_MODE() (0/*pwrCheck() == e_power_trainer*/)
|
||||
|
||||
#if !defined(SIMU)
|
||||
#define wdt_disable()
|
||||
#define wdt_enable(x)
|
||||
#define wdt_reset()
|
||||
#endif
|
||||
|
||||
uint32_t pwrCheck();
|
||||
|
||||
#define setBacklight(xx)
|
||||
#define __BACKLIGHT_ON GPIO_SetBits(GPIOB, GPIO_Pin_BL)
|
||||
#define __BACKLIGHT_OFF GPIO_ResetBits(GPIOB, GPIO_Pin_BL)
|
||||
#define IS_BACKLIGHT_ON() GPIO_IsSet(GPIOB, GPIO_Pin_BL)
|
||||
|
||||
#if !defined(SIMU)
|
||||
#define eeprom_read_block I2C_EE_BufferRead
|
||||
#define eeWriteBlockCmp I2C_EE_BufferWrite
|
||||
#else
|
||||
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
||||
#endif
|
||||
|
||||
void keysInit();
|
||||
void pwrInit();
|
||||
void eepromInit(); // TODO check it's not in another include
|
||||
void delaysInit();
|
||||
void adcInit();
|
||||
void debugInit();
|
||||
|
||||
void adcRead();
|
||||
void init_trainer_ppm();
|
||||
void init_trainer_capture();
|
||||
extern volatile uint16_t Analog_values[];
|
||||
|
||||
|
||||
#define DEBUG_UART_BAUDRATE 115200
|
||||
|
||||
@@ -138,4 +105,47 @@ void uartSendChar(uint8_t c);
|
||||
void delaysInit(void);
|
||||
void delay_01us(uint16_t nb);
|
||||
|
||||
// Keys driver
|
||||
void keysInit();
|
||||
uint32_t readKeys();
|
||||
#define KEYS_PRESSED() (~readKeys())
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & (0x20 + 0x40)) == (0x20 + 0x40))
|
||||
#define DBLKEYS_PRESSED_UP_DWN(i) ((in & (0x10 + 0x08)) == (0x10 + 0x08))
|
||||
#define DBLKEYS_PRESSED_RGT_UP(i) ((in & (0x20 + 0x10)) == (0x20 + 0x10))
|
||||
#define DBLKEYS_PRESSED_LFT_DWN(i) ((in & (0x40 + 0x08)) == (0x40 + 0x08))
|
||||
|
||||
// WDT driver
|
||||
#if !defined(SIMU)
|
||||
#define wdt_disable()
|
||||
#define wdt_enable(x)
|
||||
#define wdt_reset()
|
||||
#endif
|
||||
|
||||
// ADC driver
|
||||
void adcInit();
|
||||
void adcRead();
|
||||
extern volatile uint16_t Analog_values[];
|
||||
|
||||
// Power driver
|
||||
void pwrInit();
|
||||
uint32_t pwrCheck();
|
||||
|
||||
// Backlight driver
|
||||
#define setBacklight(xx)
|
||||
#define __BACKLIGHT_ON GPIO_SetBits(GPIOB, GPIO_Pin_BL)
|
||||
#define __BACKLIGHT_OFF GPIO_ResetBits(GPIOB, GPIO_Pin_BL)
|
||||
#define IS_BACKLIGHT_ON() GPIO_IsSet(GPIOB, GPIO_Pin_BL)
|
||||
|
||||
// EEPROM driver
|
||||
#if !defined(SIMU)
|
||||
#define eepromInit() I2C_EE_Init()
|
||||
#define eeprom_read_block I2C_EE_BufferRead
|
||||
#define eeWriteBlockCmp I2C_EE_BufferWrite
|
||||
#else
|
||||
#define eepromInit()
|
||||
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* open9x is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../open9x.h"
|
||||
|
||||
void eepromInit()
|
||||
{
|
||||
#if !defined(SIMU)
|
||||
I2C_EE_Init();
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/ee_drivers/i2c_ee.c
|
||||
* @file Project/ee_drivers/i2c.c
|
||||
* @author X9D Application Team
|
||||
* @version V 0.2
|
||||
* @date 12-JULY-2012
|
||||
@@ -370,3 +370,32 @@ void I2C_EE_WaitEepromStandbyState(void)
|
||||
|
||||
I2C_STOP();
|
||||
}
|
||||
|
||||
void I2C_set_volume( register uint8_t volume )
|
||||
{
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(I2C_CAT5137_ADDRESS|EE_CMD_WRITE);
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA(0);
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA(volume);
|
||||
I2C_WAIT_ACK();
|
||||
I2C_STOP();
|
||||
}
|
||||
|
||||
uint8_t I2C_read_volume()
|
||||
{
|
||||
uint8_t volume ;
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(I2C_CAT5137_ADDRESS|EE_CMD_WRITE);
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA(0);
|
||||
I2C_WAIT_ACK();
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(I2C_CAT5137_ADDRESS|EE_CMD_READ);
|
||||
I2C_WAIT_ACK();
|
||||
volume = I2C_READ();
|
||||
I2C_NO_ACK();
|
||||
I2C_STOP();
|
||||
return volume ;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* @author X9D Application Team
|
||||
* @version V 0.2
|
||||
* @date 12-JLY-2012
|
||||
* @brief Header for i2c_ee.c module
|
||||
* @brief Header for i2c.c module
|
||||
******************************************************************************
|
||||
* @copy
|
||||
*
|
||||
@@ -18,13 +18,11 @@
|
||||
* <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2>
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion ------------------------------------ */
|
||||
#ifndef __I2C_EE_H
|
||||
#define __I2C_EE_H
|
||||
#ifndef __I2C_H
|
||||
#define __I2C_H
|
||||
|
||||
#define EE_CMD_WRITE (0)
|
||||
#define EE_CMD_READ (1)
|
||||
//#define I2C_delay() //do { delayUsec(5); } while(0)
|
||||
|
||||
#define SCL_H do{I2C_EE_GPIO->BSRRL = I2C_EE_SCL;}while(0)
|
||||
#define SCL_L do{I2C_EE_GPIO->BSRRH = I2C_EE_SCL;}while(0)
|
||||
@@ -43,6 +41,9 @@ void I2C_EE_BufferWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteTo
|
||||
void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead);
|
||||
void I2C_EE_WaitEepromStandbyState(void);
|
||||
|
||||
void I2C_set_volume(register uint8_t volume);
|
||||
uint8_t I2C_read_volume();
|
||||
|
||||
#endif /* __I2C_EE_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user