[ACT] Navigation & Menus

This commit is contained in:
bsongis
2013-01-15 18:22:54 +00:00
parent 9537c3f940
commit 3a852e9be1
49 changed files with 832 additions and 674 deletions
+9 -12
View File
@@ -182,10 +182,6 @@ UNITS = METRIC
# Values = YES, NO
EEPROM_PROGRESS_BAR = NO
# Enable extra rotary encoders (Gruvin9x board only)
# Values = YES, NO
EXTRA_ROTARY_ENCODERS = NO
# Activates the DEBUG Mode (all boards)
# On G9X V4 board, when VOICE=NO:
# PORTH:7 --> Transistion LOW to HIGH = start of setupPulses(). Transistion HIGH to LOW = end of setupPulses().
@@ -471,14 +467,14 @@ RUN_FROM_FLASH = 1
ifeq ($(PCB), ACT)
# ACT radio
OPT = 2
CPPDEFS += -DPCBACT -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 -DLCD=260 -DSTM32F10X_HD
CPPDEFS += -DPCBACT -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX -DDSM2 -DDSM2_PPM -DSTM32F10X_HD
EXTRAINCDIRS += sky9x CoOS/kernel CoOS/portable
EXTRAINCDIRS += act/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc act/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x
BOARDSRC = act/board_act.cpp
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 x9d/audio_driver.cpp
CPPSRC += x9d/eeprom_driver.cpp x9d/pulses_driver.cpp act/keys_driver.cpp act/audio_driver.cpp
CPPSRC += sky9x/audio.cpp
PULSESSRC = pulses_arm.cpp
CPPSRC += monitors_views.cpp
@@ -487,7 +483,7 @@ endif
ifeq ($(PCB), X9D)
# X9D radio
OPT = 2
CPPDEFS += -DPCBX9D -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 -DLCD=212
CPPDEFS += -DPCBX9D -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX -DDSM2 -DDSM2_PPM
EXTRAINCDIRS += sky9x 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
@@ -541,7 +537,7 @@ ifeq ($(PCB), SKY9X)
EEPROMSRC = eeprom_arm.cpp eeprom_conversions.cpp
PULSESSRC = pulses_arm.cpp
CPPSRC += sky9x/audio.cpp haptic.cpp
CPPSRC += sky9x/pwr_driver.cpp sky9x/eeprom_driver.cpp sky9x/pulses_driver.cpp sky9x/keys_driver.cpp sky9x/audio_driver.cpp sky9x/haptic_driver.cpp sky9x/sdcard_driver.cpp sky9x/massstorage.cpp
CPPSRC += sky9x/pwr_driver.cpp sky9x/eeprom_driver.cpp sky9x/pulses_driver.cpp sky9x/keys_driver.cpp sky9x/audio_driver.cpp sky9x/haptic_driver.cpp sky9x/sdcard_driver.cpp sky9x/massstorage.cpp
ifeq ($(SDCARD), YES)
EXTRAINCDIRS += FatFs FatFs/option
@@ -569,7 +565,7 @@ endif
ifeq ($(PCB), GRUVIN9X)
# 9x radio with a gruvin9x replacement board
OPT = 2
CPPDEFS += -DPCBGRUVIN9X -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC -DROTARY_ENCODERS=2
CPPDEFS += -DPCBGRUVIN9X -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC
EXTRAINCDIRS += gruvin9x stock FatFs FatFs/option
BOARDSRC += gruvin9x/board_gruvin9x.cpp
EXTRABOARDSRC += stock/lcd_driver.cpp
@@ -588,9 +584,10 @@ ifeq ($(PCB), GRUVIN9X)
CPPDEFS += -DVOICE
endif
ifeq ($(EXTRA_ROTARY_ENCODERS), YES)
CPPDEFS += -DEXTRA_ROTARY_ENCODERS
endif
# Enable extra rotary encoders (Gruvin9x board only)
# Values = YES, NO
ROTARY_ENCODERS = 2
CPPDEFS += -DROTARY_ENCODERS=${ROTARY_ENCODERS}
endif
ifeq ($(PCB), STD128)
+99
View File
@@ -0,0 +1,99 @@
/*
* 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"
volatile uint8_t Buzzer_count ;
// Must NOT be in flash, PDC needs a RAM source.
// Amplitude reduced to 30% to allow for voice volume
uint16_t Sine_values[] =
{
2048,2085,2123,2160,2197,2233,2268,2303,2336,2369,
2400,2430,2458,2485,2510,2533,2554,2573,2590,2605,
2618,2629,2637,2643,2646,2648,2646,2643,2637,2629,
2618,2605,2590,2573,2554,2533,2510,2485,2458,2430,
2400,2369,2336,2303,2268,2233,2197,2160,2123,2085,
2048,2010,1972,1935,1898,1862,1826,1792,1758,1726,
1695,1665,1637,1610,1585,1562,1541,1522,1505,1490,
1477,1466,1458,1452,1448,1448,1448,1452,1458,1466,
1477,1490,1505,1522,1541,1562,1585,1610,1637,1665,
1695,1726,1758,1792,1826,1862,1898,1935,1972,2010
};
// Sound routines
void startSound()
{
}
uint32_t currentFrequency = 0;
uint32_t getFrequency()
{
return currentFrequency;
}
void setFrequency(uint32_t frequency)
{
if (currentFrequency != frequency) {
currentFrequency = frequency;
}
}
// Start TIMER1 at 100000Hz, used for DACC trigger
void start_timer1()
{
}
// Configure DAC0 (or DAC1 for REVA)
// Not sure why PB14 has not be allocated to the DAC, although it is an EXTRA function
// So maybe it is automatically done
void initDac()
{
}
void end_sound()
{
}
// Set up for volume control (TWI0)
// Need PA3 and PA4 set to peripheral A
void init_twi()
{
}
void setVolume( unsigned char volume )
{
}
+33 -8
View File
@@ -41,14 +41,16 @@
#include "stm32f10x.h"
// Keys
#define PIN_BUTTON_PLUS GPIO_Pin_0 //SW3 PE.10
#define PIN_BUTTON_ENTER GPIO_Pin_1 //SW2 PE.11
#define PIN_BUTTON_MINUS GPIO_Pin_2 //SW1 PE.12
#define PIN_BUTTON_MENU GPIO_Pin_11 //SW4 PD.07
#define PIN_BUTTON_EXIT GPIO_Pin_12 //SW5 PD.03
#define PIN_BUTTON_PAGE GPIO_Pin_10 //SW6 PD.02
#include "x9d/audio_driver.h"
#define GPIO_BUTTON_MENU GPIOC->IDR
#define GPIO_BUTTON_EXIT GPIOC->IDR
#define GPIO_BUTTON_CLR GPIOC->IDR
#define GPIO_BUTTON_PAGE GPIOC->IDR
#define GPIO_BUTTON_ENTER GPIOC->IDR
#define PIN_BUTTON_MENU GPIO_Pin_11
#define PIN_BUTTON_EXIT GPIO_Pin_12
#define PIN_BUTTON_CLR GPIO_Pin_13
#define PIN_BUTTON_PAGE GPIO_Pin_10
#define PIN_BUTTON_ENTER GPIO_Pin_14
// TODO elsewhere
#if !defined(SIMU)
@@ -123,4 +125,27 @@ extern uint16_t sessionTimer;
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size);
#endif
#define NUM_VOL_LEVELS 24
void startSound( void ) ;
void setFrequency( uint32_t frequency );
uint32_t getFrequency();
void start_timer1( void );
void initDac( void ) ;
void end_sound( void ) ;
extern uint16_t *nextAudioData;
extern uint16_t nextAudioSize;
inline void toneStart()
{
}
inline void toneStop()
{
}
extern void init_twi( void ) ;
extern void setVolume( register uint8_t volume ) ;
#endif
+16 -18
View File
@@ -37,24 +37,20 @@
uint32_t readKeys()
{
register uint32_t x = GPIOC->IDR;
register uint32_t y = 0;
register uint32_t result = 0;
if (x & 0x00000020)
y |= 0x02 << KEY_ENTER;
if (x & 0x00000010)
y |= 0x02 << KEY_PLUS;
if (x & 0x00000008)
y |= 0x02 << KEY_MINUS;
if (x & 0x00000002)
y |= 0x02 << KEY_MENU;
if (x & 0x00000040)
y |= 0x02 << KEY_PAGE;
if (x & 0x01000000)
y |= 0x02 << KEY_EXIT;
if (x & PIN_BUTTON_MENU)
result |= 0x02 << KEY_MENU;
if (x & PIN_BUTTON_EXIT)
result |= 0x02 << KEY_EXIT;
if (x & PIN_BUTTON_CLR)
result |= 0x02 << KEY_CLR;
if (x & PIN_BUTTON_PAGE)
result |= 0x02 << KEY_PAGE;
// printf("readKeys(): %x => %x\n", x, y); fflush(stdout);
// printf("readKeys(): %x => %x\n", x, result); fflush(stdout);
return y ;
return result;
}
uint32_t readTrims()
@@ -64,7 +60,7 @@ uint32_t readTrims()
uint8_t keyDown()
{
return ~readKeys() & 0x6C ;
return ~readKeys() & 0x1e ;
}
/* TODO common to ARM */
@@ -74,7 +70,7 @@ void readKeysAndTrims()
uint8_t enuk = KEY_MENU;
uint8_t in = ~readKeys();
for (i = 1; i < 7; i++) {
for (i = 1; i < 5; i++) {
keys[enuk].input(in & (1 << i), (EnumKeys) enuk);
++enuk;
}
@@ -85,9 +81,11 @@ void readKeysAndTrims()
keys[enuk].input(in & i, (EnumKeys) enuk);
++enuk;
} */
keys[BTN_REa].input(!(GPIO_BUTTON_ENTER & PIN_BUTTON_ENTER), BTN_REa);
}
uint32_t keyState(EnumKeys enuk)
uint32_t switchState(EnumKeys enuk)
{
return 0;
}
+2 -2
View File
@@ -213,7 +213,7 @@ const pm_char * bmpLoad(uint8_t *dest, const char *filename, const xcoord_t widt
void lcd_bmp(xcoord_t x, uint8_t y, const pm_uchar * img)
{
const pm_uchar *q = img;
#if LCD >= 260
#if LCD_W >= 260
xcoord_t w = pgm_read_byte(q++);
if (w == 255) w += pgm_read_byte(q++);
#else
@@ -221,7 +221,7 @@ void lcd_bmp(xcoord_t x, uint8_t y, const pm_uchar * img)
#endif
uint8_t hb = (pgm_read_byte(q++)+7)/8;
for (uint8_t yb = 0; yb < hb; yb++) {
uint8_t *p = &displayBuf[ (y / 8 + yb) * DISPLAY_W + x ];
uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ];
for (xcoord_t i=0; i<w; i++){
*(p+0*DISPLAY_PLAN_SIZE) = pgm_read_byte(q++);
*(p+1*DISPLAY_PLAN_SIZE) = pgm_read_byte(q++);
-3
View File
@@ -73,9 +73,6 @@ void debugTask(void* pdata);
#define TRACE_ERROR(...) { }
#define DUMP(...) { }
#define DEBUG_UART_Configure(...)
#define DEBUG_UART_Stop(...)
#endif
#endif
+27 -27
View File
@@ -71,12 +71,12 @@ const MenuFuncP_PROGMEM menuTabDiag[] PROGMEM = {
menuGeneralCalib
};
#if LCD >= 212
#define RADIO_SETUP_2ND_COLUMN (DISPLAY_W-10*FW-MENUS_SCROLLBAR_WIDTH)
#if LCD_W >= 212
#define RADIO_SETUP_2ND_COLUMN (LCD_W-10*FW-MENUS_SCROLLBAR_WIDTH)
#define RADIO_SETUP_DATE_COLUMN RADIO_SETUP_2ND_COLUMN + 4*FWNUM
#define RADIO_SETUP_TIME_COLUMN RADIO_SETUP_2ND_COLUMN + 2*FWNUM
#else
#define RADIO_SETUP_2ND_COLUMN (DISPLAY_W-5*FW-MENUS_SCROLLBAR_WIDTH)
#define RADIO_SETUP_2ND_COLUMN (LCD_W-5*FW-MENUS_SCROLLBAR_WIDTH)
#define RADIO_SETUP_TIME_COLUMN (FW*15+5)
#define RADIO_SETUP_DATE_COLUMN (FW*15+5)
#endif
@@ -155,8 +155,8 @@ void menuGeneralSetup(uint8_t event)
uint8_t sub = m_posVert - 1;
for (uint8_t i=0; i<7; i++) {
uint8_t y = 1*FH + i*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y = 1 + 1*FH + i*FH;
uint8_t k = i+s_pgOfs;
uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
uint8_t attr = (sub == k ? blink : 0);
@@ -609,7 +609,7 @@ void menuGeneralSdManager(uint8_t event)
bool isfile = !(fno.fattrib & AM_DIR);
if (s_pgOfs == 0) {
for (uint8_t i=0; i<7; i++) {
for (uint8_t i=0; i<LCD_LINES-1; i++) {
char *line = reusableBuffer.sd.lines[i];
if (line[0] == '\0' || isFilenameLower(isfile, fn, line)) {
if (i < 6) memmove(reusableBuffer.sd.lines[i+1], line, sizeof(reusableBuffer.sd.lines[i]) * (6-i));
@@ -652,8 +652,8 @@ void menuGeneralSdManager(uint8_t event)
reusableBuffer.sd.offset = s_pgOfs;
for (uint8_t i=0; i<7; i++) {
uint8_t y = FH+i*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y = 1 + FH + i*FH;
uint8_t x = 0;
uint8_t attr = (m_posVert-1-s_pgOfs == i ? BSS|INVERS : BSS);
if (reusableBuffer.sd.lines[i][0]) {
@@ -731,9 +731,9 @@ void menuGeneralTrainer(uint8_t event)
uint8_t attr;
uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
lcd_puts(3*FW, 1*FH, STR_MODESRC);
lcd_puts(3*FW, 1 + 1*FH, STR_MODESRC);
y = 2*FH;
y = 1 + 2*FH;
for (uint8_t i=1; i<=NUM_STICKS; i++) {
uint8_t chan = channel_order(i);
@@ -766,18 +766,18 @@ void menuGeneralTrainer(uint8_t event)
}
attr = (m_posVert==5) ? blink : 0;
lcd_putsLeft(6*FH, STR_MULTIPLIER);
lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, 6*FH, g_eeGeneral.PPM_Multiplier+10, attr|PREC1);
lcd_putsLeft(6*FH+1, STR_MULTIPLIER);
lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, 6*FH+1, g_eeGeneral.PPM_Multiplier+10, attr|PREC1);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40);
attr = (m_posVert==6) ? blink : 0;
lcd_putsAtt(0*FW, 7*FH, STR_CAL, attr);
lcd_putsAtt(0*FW, 1+7*FH, STR_CAL, attr);
for (uint8_t i=0; i<4; i++) {
uint8_t x = (i*8+16)*FW/2;
#if defined (PPM_UNIT_PERCENT_PREC1)
lcd_outdezAtt(x, 7*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])*2, PREC1);
lcd_outdezAtt(x, 1+7*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])*2, PREC1);
#else
lcd_outdezAtt(x, 7*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])/5, 0);
lcd_outdezAtt(x, 1+7*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])/5, 0);
#endif
}
@@ -813,7 +813,7 @@ void menuGeneralVersion(uint8_t event)
void displayKeyState(uint8_t x, uint8_t y, EnumKeys key)
{
uint8_t t = keyState(key);
uint8_t t = switchState(key);
lcd_putcAtt(x, y, t+'0', t ? INVERS : 0);
}
@@ -848,7 +848,7 @@ void menuGeneralDiagKeys(uint8_t event)
for(uint8_t i=0; i<ROTARY_ENCODERS; i++) {
uint8_t y = i*FH + FH;
lcd_putsiAtt(14*FW, y, STR_VRENCODERS, i, 0);
lcd_outdezNAtt(18*FW, y, g_rotenc[i], LEFT|(keyState((EnumKeys)(BTN_REa+i)) ? INVERS : 0));
lcd_outdezNAtt(18*FW, y, g_rotenc[i], LEFT|(switchState((EnumKeys)(BTN_REa+i)) ? INVERS : 0));
}
#endif
@@ -882,12 +882,12 @@ void menuGeneralDiagAna(uint8_t event)
#endif
#if defined(PCBSKY9X)
lcd_putsLeft(5*FH, STR_BATT_CALIB);
lcd_putsLeft(5*FH+1, STR_BATT_CALIB);
static uint32_t adcBatt;
adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; // running average, sourced directly (to avoid unending debate :P)
uint32_t batCalV = ( adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128 ) * 4191 ;
batCalV /= 55296 ;
putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH, batCalV, (m_posVert==1 ? INVERS : 0));
putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH+1, batCalV, (m_posVert==1 ? INVERS : 0));
#elif defined(PCBGRUVIN9X)
lcd_putsLeft(6*FH-2, STR_BATT_CALIB);
// Gruvin wants 2 decimal places and instant update of volts calib field when button pressed
@@ -896,12 +896,12 @@ void menuGeneralDiagAna(uint8_t event)
uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.vBatCalib)/8) / BandGap;
lcd_outdezNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(m_posVert==1 ? INVERS : 0));
#elif defined(PCBX9D)
lcd_putsLeft(5*FH, STR_BATT_CALIB);
lcd_putsLeft(5*FH+1, STR_BATT_CALIB);
static uint32_t adcBatt;
adcBatt = ((adcBatt * 7) + anaIn(8)) / 8; // running average, sourced directly (to avoid unending debate :P)
uint32_t batCalV = ( adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128 ) * 15 ;
batCalV /= 256 ;
putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH, batCalV, (m_posVert==1 ? INVERS : 0));
putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH+1, batCalV, (m_posVert==1 ? INVERS : 0));
#else
lcd_putsLeft(6*FH-2, STR_BATT_CALIB);
putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0));
@@ -909,14 +909,14 @@ void menuGeneralDiagAna(uint8_t event)
if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127);
#if defined(PCBSKY9X) && !defined(REVA)
lcd_putsLeft(6*FH, STR_CURRENT_CALIB);
putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 6*FH, getCurrent(), UNIT_MILLIAMPS, (m_posVert==2 ? INVERS : 0)) ;
lcd_putsLeft(6*FH+1, STR_CURRENT_CALIB);
putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, getCurrent(), UNIT_MILLIAMPS, (m_posVert==2 ? INVERS : 0)) ;
if (m_posVert==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.currentCalib, -49, 49);
#endif
#if defined(CPUARM)
lcd_putsLeft(7*FH, STR_TEMP_CALIB);
putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 7*FH, getTemperature(), UNIT_DEGREES, (m_posVert==3 ? INVERS : 0)) ;
lcd_putsLeft(7*FH+1, STR_TEMP_CALIB);
putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 7*FH+1, getTemperature(), UNIT_DEGREES, (m_posVert==3 ? INVERS : 0)) ;
if (m_posVert==3) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureCalib, -100, 100);
#endif
}
@@ -940,8 +940,8 @@ void menuGeneralHardware(uint8_t event)
uint8_t sub = m_posVert - 1;
for (uint8_t i=0; i<7; i++) {
uint8_t y = 1*FH + i*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y = 1 + 1*FH + i*FH;
uint8_t k = i+s_pgOfs;
uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
uint8_t attr = (sub == k ? blink : 0);
+10 -13
View File
@@ -97,7 +97,7 @@ inline void boardInit()
EICRA = (1<<ISC30) | (1<<ISC20); // do the same for encoder 1
EIFR = (3<<INTF2);
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
EIMSK = (3<<INT5); // enable the ONE rot. enc. ext. int. pairs.
#else
EIMSK = (3<<INT5) | (3<<INT2); // enable the two rot. enc. ext. int. pairs.
@@ -113,7 +113,7 @@ inline void boardInit()
TIMSK4 |= (1<<OCIE4A); // Start the interrupt so the unit reset can occur
#endif
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
//configure uart1 here
DDRD &= ~(1 << 2);
PORTD &= ~(1 << 2);
@@ -123,10 +123,10 @@ inline void boardInit()
UCSR1C = (1<<USBS1)|(3<<UCSZ10);
UCSR1B = (1<<RXEN1)|(0<<TXEN1)|(1<<UCSZ12);
UCSR1B |= 1 << RXCIE1; //enable interrupt on rx
#endif //EXTRA_ROTARY_ENCODERS
#endif
}
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
uint8_t vpotToChange = 0;
uint8_t vpot_mod_state = 0;
@@ -161,7 +161,7 @@ ISR(USART1_RX_vect)
}
}
}
#endif // EXTRA_ROTARY_ENCODERS
#endif
#endif // !SIMU
uint8_t check_soft_power()
@@ -185,7 +185,7 @@ FORCEINLINE uint8_t keyDown()
return (~PINL) & 0x3F;
}
bool keyState(EnumKeys enuk)
bool switchState(EnumKeys enuk)
{
uint8_t result = 0 ;
@@ -256,9 +256,9 @@ FORCEINLINE void readKeysAndTrims()
uint8_t enuk = KEY_MENU;
#if !defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS <= 2
keys[BTN_REa].input(~PIND & 0x20, BTN_REa);
#endif //!EXTRA_ROTARY_ENCODERS
#endif
keys[BTN_REb].input(~PIND & 0x10, BTN_REb);
uint8_t tin = ~PINL;
@@ -294,9 +294,7 @@ FORCEINLINE void readKeysAndTrims()
}
}
#if defined(ROTARY_ENCODERS)
#if !defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS <= 2
ISR(INT2_vect)
{
uint8_t input = (PIND & 0x0C);
@@ -308,7 +306,7 @@ ISR(INT3_vect)
uint8_t input = (PIND & 0x0C);
if (input == 0 || input == 0x0C) incRotaryEncoder(0, +1);
}
#endif // !defined(EXTRA_ROTARY_ENCODERS)
#endif
ISR(INT5_vect)
{
@@ -321,4 +319,3 @@ ISR(INT6_vect)
uint8_t input = (PINE & 0x60);
if (input == 0 || input == 0x60) incRotaryEncoder(1, -1);
}
#endif // defined(ROTARY_ENCODERS)
+13
View File
@@ -35,6 +35,19 @@
#ifndef board_gruvin9x_h
#define board_gruvin9x_h
#define GPIO_BUTTON_MENU pinl
#define GPIO_BUTTON_EXIT pinl
#define GPIO_BUTTON_RIGHT pinl
#define GPIO_BUTTON_LEFT pinl
#define GPIO_BUTTON_UP pinl
#define GPIO_BUTTON_DOWN pinl
#define PIN_BUTTON_MENU (1<<INP_L_KEY_MEN)
#define PIN_BUTTON_EXIT (1<<INP_L_KEY_EXT)
#define PIN_BUTTON_UP (1<<INP_L_KEY_UP)
#define PIN_BUTTON_DOWN (1<<INP_L_KEY_DWN)
#define PIN_BUTTON_RIGHT (1<<INP_L_KEY_RGT)
#define PIN_BUTTON_LEFT (1<<INP_L_KEY_LFT)
#define TIMER_16KHZ_VECT TIMER2_OVF_vect
#define COUNTER_16KHZ TCNT2
#define TIMER_10MS_VECT TIMER2_COMPA_vect
+4 -4
View File
@@ -206,10 +206,10 @@ void menuTelemetryJeti(uint8_t event)
if (JetiBufferReady)
{
JETI_EnableTXD();
if (keyState((EnumKeys)(KEY_UP))) jeti_keys &= JETI_KEY_UP;
if (keyState((EnumKeys)(KEY_DOWN))) jeti_keys &= JETI_KEY_DOWN;
if (keyState((EnumKeys)(KEY_LEFT))) jeti_keys &= JETI_KEY_LEFT;
if (keyState((EnumKeys)(KEY_RIGHT))) jeti_keys &= JETI_KEY_RIGHT;
if (switchState((EnumKeys)(KEY_UP))) jeti_keys &= JETI_KEY_UP;
if (switchState((EnumKeys)(KEY_DOWN))) jeti_keys &= JETI_KEY_DOWN;
if (switchState((EnumKeys)(KEY_LEFT))) jeti_keys &= JETI_KEY_LEFT;
if (switchState((EnumKeys)(KEY_RIGHT))) jeti_keys &= JETI_KEY_RIGHT;
JetiBufferReady = 0; // invalidate buffer
+40 -40
View File
@@ -46,7 +46,7 @@ void lcd_clear()
void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags att)
{
const pm_uchar *q = img;
#if LCD >= 260
#if LCD_W >= 260
xcoord_t w = pgm_read_byte(q++);
if (w == 255) w += pgm_read_byte(q++);
#else
@@ -56,7 +56,7 @@ void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags
bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false);
q += idx*w*hb;
for (uint8_t yb = 0; yb < hb; yb++) {
uint8_t *p = &displayBuf[ (y / 8 + yb) * DISPLAY_W + x ];
uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ];
for (xcoord_t i=0; i<w; i++){
uint8_t b = pgm_read_byte(q++);
ASSERT_IN_DISPLAY(p);
@@ -98,9 +98,9 @@ uint8_t lcdLastPos;
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
{
uint8_t *p = &displayBuf[ y / 8 * DISPLAY_W + x ];
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
#if defined(PCBX9D)
#if defined(CPUARM)
const pm_uchar *q = (c < 0xC0) ? &font_5x7[(c-0x20)*5+4] : &font_5x7_extra[(c-0xC0)*5+4];
#else
const pm_uchar *q = &font_5x7[(c-0x20)*5+4];
@@ -134,16 +134,16 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
b1 = ~b1;
b2 = ~b2;
}
if(&p[DISPLAY_W+1] < DISPLAY_END) {
if(&p[LCD_W+1] < DISPLAY_END) {
ASSERT_IN_DISPLAY(p);
ASSERT_IN_DISPLAY(p+DISPLAY_W);
ASSERT_IN_DISPLAY(p+LCD_W);
LCD_BYTE_FILTER(p, 0, b1);
LCD_BYTE_FILTER(p+DISPLAY_W, 0, b2);
LCD_BYTE_FILTER(p+LCD_W, 0, b2);
p++;
}
}
}
#if defined(PCBX9D)
#if defined(CPUARM)
else if (flags & MIDSIZE) {
/* each letter consists of ten top bytes followed by
* by ten bottom bytes (20 bytes per * char) */
@@ -160,15 +160,15 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
b2 = ~b2;
}
uint8_t ym8 = (y % 8);
if (&p[DISPLAY_W+1] < DISPLAY_END) {
if (&p[LCD_W+1] < DISPLAY_END) {
LCD_BYTE_FILTER(p, ~(0xff << ym8), b1 << ym8);
uint8_t *r = p + DISPLAY_W;
uint8_t *r = p + LCD_W;
if (r<DISPLAY_END) {
if (ym8)
LCD_BYTE_FILTER(r, ~(0xff >> (8-ym8)), b1 >> (8-ym8));
LCD_BYTE_FILTER(r, ~(0x0f << ym8), (b2&0x0f) << ym8);
if (ym8) {
r = r + DISPLAY_W;
r = r + LCD_W;
if (r<DISPLAY_END)
LCD_BYTE_FILTER(r, ~(0x0f >> (8-ym8)), (b2&0x0f) >> (8-ym8));
}
@@ -187,7 +187,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
if (p<DISPLAY_END) {
LCD_BYTE_FILTER(p, ~(0x7f << ym8), b << ym8);
if (ym8) {
uint8_t *r = p + DISPLAY_W;
uint8_t *r = p + LCD_W;
if (r<DISPLAY_END)
LCD_BYTE_FILTER(r, ~(0x7f >> (8-ym8)), b >> (8-ym8));
}
@@ -205,7 +205,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
if (p<DISPLAY_END) {
LCD_BYTE_FILTER(p, ~(0x3f << ym8), b << ym8);
if (ym8) {
uint8_t *r = p + DISPLAY_W;
uint8_t *r = p + LCD_W;
if (r<DISPLAY_END)
LCD_BYTE_FILTER(r, ~(0x3f >> (8-ym8)), b >> (8-ym8));
}
@@ -236,7 +236,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
if (p<DISPLAY_END) {
LCD_BYTE_FILTER(p, ~(0xff << ym8), b << ym8);
if (ym8) {
uint8_t *r = p + DISPLAY_W;
uint8_t *r = p + LCD_W;
if (r<DISPLAY_END)
LCD_BYTE_FILTER(r, ~(0xff >> (8-ym8)), b >> (8-ym8));
}
@@ -282,9 +282,9 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag
c = pgm_read_byte(s);
break;
}
if (!c || x>DISPLAY_W-6) break;
if (!c || x>LCD_W-6) break;
if (c >= 0x20) {
#if defined(PCBX9D)
#if defined(CPUARM)
if ((mode & MIDSIZE) && ((c>='a'&&c<='z')||(c>='0'&&c<='9'))) {
lcd_putcAtt(x, y, c, mode);
x-=1;
@@ -304,7 +304,7 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag
len--;
}
lcdLastPos = x;
#if defined(PCBX9D)
#if defined(CPUARM)
if (mode&MIDSIZE)
lcdLastPos += 1;
#endif
@@ -358,7 +358,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, int16_t val, LcdFlags flags, uint8_t
uint8_t fw = FWNUM;
int8_t mode = MODE(flags);
bool dblsize = flags & DBLSIZE;
#if defined(PCBX9D)
#if defined(CPUARM)
bool midsize = flags & MIDSIZE;
bool tinsize = flags & TINSIZE;
#else
@@ -526,17 +526,17 @@ void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att)
void lcd_plot(xcoord_t x, uint8_t y, LcdFlags att)
{
uint8_t *p = &displayBuf[ y / 8 * DISPLAY_W + x ];
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
if (p<DISPLAY_END)
lcd_mask(p, BITMASK(y%8), att);
}
void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att)
{
if (y >= DISPLAY_H) return;
if (x+w > DISPLAY_W) { w = DISPLAY_W - x; }
if (y >= LCD_H) return;
if (x+w > LCD_W) { w = LCD_W - x; }
uint8_t *p = &displayBuf[ y / 8 * DISPLAY_W + x ];
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
uint8_t msk = BITMASK(y%8);
while(w) {
if(pat&1) {
@@ -559,31 +559,31 @@ void lcd_hline(xcoord_t x, uint8_t y, xcoord_t w, LcdFlags att)
#if defined(PCBSTD)
void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat)
{
if (x >= DISPLAY_W) return;
if (x >= LCD_W) return;
if (h<0) { y+=h; h=-h; }
if (y<0) { h+=y; y=0; }
if (y+h > DISPLAY_H) { h = DISPLAY_H - y; }
if (y+h > LCD_H) { h = LCD_H - y; }
if (pat==DOTTED && !(y%2))
pat = ~pat;
uint8_t *p = &displayBuf[ y / 8 * DISPLAY_W + x ];
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
y = y % 8;
if (y) {
ASSERT_IN_DISPLAY(p);
*p ^= ~(BITMASK(y)-1) & pat;
p += DISPLAY_W;
p += LCD_W;
h -= 8-y;
}
while (h>0) {
ASSERT_IN_DISPLAY(p);
*p ^= pat;
p += DISPLAY_W;
p += LCD_W;
h -= 8;
}
if (h < 0) h += 8;
if (h) {
p -= DISPLAY_W;
p -= LCD_W;
ASSERT_IN_DISPLAY(p);
*p ^= ~(BITMASK(h)-1) & pat;
}
@@ -592,15 +592,15 @@ void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat)
// allows the att parameter...
void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att)
{
if (x >= DISPLAY_W) return;
if (x >= LCD_W) return;
if (h<0) { y+=h; h=-h; }
if (y<0) { h+=y; y=0; }
if (y+h > DISPLAY_H) { h = DISPLAY_H - y; }
if (y+h > LCD_H) { h = LCD_H - y; }
if (pat==DOTTED && !(y%2))
pat = ~pat;
uint8_t *p = &displayBuf[ y / 8 * DISPLAY_W + x ];
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
y = y % 8;
if (y) {
ASSERT_IN_DISPLAY(p);
@@ -609,12 +609,12 @@ void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att)
if (h < 0)
msk -= ~(BITMASK(8+h)-1);
lcd_mask(p, msk & pat, att);
p += DISPLAY_W;
p += LCD_W;
}
while (h>=8) {
ASSERT_IN_DISPLAY(p);
lcd_mask(p, pat, att);
p += DISPLAY_W;
p += LCD_W;
h -= 8;
}
if (h>0) {
@@ -641,15 +641,15 @@ void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlag
void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlags att)
{
for (int8_t i=y; i<y+h; i++) {
if (i>=0 && i<DISPLAY_H) lcd_hlineStip(x, i, w, pat, att);
if (i>=0 && i<LCD_H) lcd_hlineStip(x, i, w, pat, att);
pat = (pat >> 1) + ((pat & 1) << 7);
}
}
void lcd_invert_line(int8_t y)
{
uint8_t *p = &displayBuf[y * DISPLAY_W];
for (xcoord_t x=0; x<DISPLAY_W; x++) {
uint8_t *p = &displayBuf[y * LCD_W];
for (xcoord_t x=0; x<LCD_W; x++) {
ASSERT_IN_DISPLAY(p);
#if defined(PCBX9D)
*(p+3*DISPLAY_PLAN_SIZE) ^= 0xff;
@@ -673,7 +673,7 @@ void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2
qr = div(tme, 60);
#if defined(PCBX9D)
#if defined(CPUARM)
if (att & MIDSIZE) {
div_t qr2 = div(qr.quot, 60);
LCD_2DOTS(x+2*8-6, y, att);
@@ -705,7 +705,7 @@ void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2
x3 = x+2*FWNUM-1+FW;
}
#if defined(PCBX9D)
#if defined(CPUARM)
if (att&MIDSIZE) {
LCD_2DOTS(x2, y, att);
}
@@ -751,7 +751,7 @@ void putsChnRaw(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att)
void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att)
{
#if defined(PCBX9D)
#if defined(PCBX9D) || defined(PCBACT)
if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW)
putsChnRaw(x, y, idx, att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CSW)
@@ -872,7 +872,7 @@ void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags at
#if defined(ROTARY_ENCODERS)
void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att)
{
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
int16_t v;
if(idx < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
v = phaseaddress(phase)->rotaryEncoders[idx];
+24 -14
View File
@@ -35,26 +35,33 @@
#ifndef lcd_h
#define lcd_h
#if LCD >= 260
#define DISPLAY_W 260
#define DISPLAY_H 75
#if defined(PCBACT)
#define LCD_W 260
#define LCD_H 75
#define xcoord_t uint16_t
#define CENTER "\015"
#define CENTER_OFS (7*FW-FW/2)
#elif LCD >= 212
#define DISPLAY_W 212
#define DISPLAY_H 64
#elif defined(PCBX9D)
#define LCD_W 212
#define LCD_H 64
#define xcoord_t uint16_t
#define CENTER "\015"
#define CENTER_OFS (7*FW-FW/2)
#else
#define DISPLAY_W 128
#define DISPLAY_H 64
#define LCD_W 128
#define LCD_H 64
#define xcoord_t uint8_t
#define CENTER
#define CENTER_OFS 0
#endif
#if LCD_H > 64
#define LCD_LINES 9
#else
#define LCD_LINES 8
#endif
#define FW 6
#define FWNUM 5
#define FH 8
@@ -100,25 +107,28 @@
/* telemetry flags */
#define NO_UNIT 0x40
#if defined(PCBX9D)
#if defined(CPUARM)
#define MIDSIZE 0x0100
#define SMLSIZE 0x0200
#define TINSIZE 0x0400
#define GREY(x) ((x)*0x1000)
#define GREY_MASK(x) ((x) & 0xF000)
#else
#define MIDSIZE DBLSIZE
#define SMLSIZE 0x00
#define TINSIZE 0x00
#endif
#if defined(PCBX9D)
#define GREY(x) ((x) * 0x1000)
#define GREY_MASK(x) ((x) & 0xF000)
#endif
#if defined(CPUARM)
#define LcdFlags uint32_t
#else
#define LcdFlags uint8_t
#endif
#define DISPLAY_PLAN_SIZE (DISPLAY_W*((DISPLAY_H+7)/8))
#define DISPLAY_PLAN_SIZE (LCD_W*((LCD_H+7)/8))
#if defined(PCBX9D)
#define DISPLAY_BUF_SIZE (4*DISPLAY_PLAN_SIZE)
@@ -146,7 +156,7 @@ extern void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s,unsigned char
extern void lcd_puts(xcoord_t x, uint8_t y, const pm_char * s);
extern void lcd_putsn(xcoord_t x, uint8_t y, const pm_char * s, unsigned char len);
extern void lcd_putsLeft(uint8_t y, const pm_char * s);
#define lcd_putsCenter(y, s) lcd_puts((DISPLAY_W-sizeof(TR_##s)*FW+FW-2)/2, y, STR_##s)
#define lcd_putsCenter(y, s) lcd_puts((LCD_W-sizeof(TR_##s)*FW+FW-2)/2, y, STR_##s)
extern void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val);
extern void lcd_outdezAtt(xcoord_t x, uint8_t y, int16_t val, LcdFlags mode=0);
@@ -196,7 +206,7 @@ extern void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags
extern void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat=SOLID, LcdFlags att=0);
extern void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat=SOLID, LcdFlags att=0);
extern void lcd_invert_line(int8_t y);
#define lcd_status_line() lcd_invert_line(7)
#define lcd_status_line() lcd_invert_line(LCD_LINES-1)
inline void lcd_square(xcoord_t x, uint8_t y, xcoord_t w, LcdFlags att=0) { lcd_rect(x, y, w, w, SOLID, att); }
#define DO_CROSS(xx,yy,ww) \
+1 -1
View File
@@ -203,7 +203,7 @@ void writeLogs()
f_printf(&g_oLogFile, "%d,", calibratedStick[i]);
}
if (f_printf(&g_oLogFile, "%d,%d,%d,%d,%d,%d,%d,%d,%d\n", keyState(SW_THR), keyState(SW_RUD), keyState(SW_ELE), keyState(SW_ID0), keyState(SW_ID1), keyState(SW_ID2), keyState(SW_AIL), keyState(SW_GEA), keyState(SW_TRN)) < 0 && !error_displayed) {
if (f_printf(&g_oLogFile, "%d,%d,%d,%d,%d,%d,%d,%d,%d\n", switchState(SW_THR), switchState(SW_RUD), switchState(SW_ELE), switchState(SW_ID0), switchState(SW_ID1), switchState(SW_ID2), switchState(SW_AIL), switchState(SW_GEA), switchState(SW_TRN)) < 0 && !error_displayed) {
error_displayed = STR_SDCARD_ERROR;
s_global_warning = STR_SDCARD_ERROR;
}
+37 -37
View File
@@ -34,36 +34,36 @@
#include "open9x.h"
#if LCD >= 212
#if LCD_W >= 212
#define BOX_WIDTH 31
#define LBOX_CENTERX (BOX_WIDTH/2 + 17)
#define LBOX_CENTERY (DISPLAY_H-BOX_WIDTH/2-10)
#define RBOX_CENTERX (DISPLAY_W-LBOX_CENTERX)
#define LBOX_CENTERY (LCD_H-BOX_WIDTH/2-10)
#define RBOX_CENTERX (LCD_W-LBOX_CENTERX)
#define RBOX_CENTERY LBOX_CENTERY
#define MODELNAME_X (13)
#define VBATT_X (MODELNAME_X+26)
#define VBATT_Y (FH+3)
#define VBATTUNIT_X (VBATT_X-2)
#define VBATTUNIT_Y VBATT_Y
#define BITMAP_X ((DISPLAY_W-64)/2)
#define BITMAP_Y (DISPLAY_H/2)
#define BITMAP_X ((LCD_W-64)/2)
#define BITMAP_Y (LCD_H/2)
#define PHASE_X BITMAP_X
#define PHASE_Y (3*FH)
#define TIMERS_X 144
#define TIMERS_R 192
#define REBOOT_X (DISPLAY_W-FW)
#define REBOOT_X (LCD_W-FW)
#define VSWITCH_X(i) (((i>=NUM_CSW*3/4) ? BITMAP_X+28 : ((i>=NUM_CSW/2) ? BITMAP_X+25 : ((i>=NUM_CSW/4) ? 21 : 18))) + 3*i)
#define VSWITCH_Y (DISPLAY_H-9)
#define VSWITCH_Y (LCD_H-9)
#define BAR_HEIGHT (31-9)
#define TRIM_LH_X (32+9)
#define TRIM_LV_X 10
#define TRIM_RV_X (DISPLAY_W-11)
#define TRIM_RH_X (DISPLAY_W-32-9)
#define TRIM_RV_X (LCD_W-11)
#define TRIM_RH_X (LCD_W-32-9)
#else
#define BOX_WIDTH 23
#define LBOX_CENTERX (DISPLAY_W/4 + 10)
#define LBOX_CENTERY (DISPLAY_H-9-BOX_WIDTH/2)
#define RBOX_CENTERX (3*DISPLAY_W/4 - 10)
#define LBOX_CENTERX (LCD_W/4 + 10)
#define LBOX_CENTERY (LCD_H-9-BOX_WIDTH/2)
#define RBOX_CENTERX (3*LCD_W/4 - 10)
#define RBOX_CENTERY LBOX_CENTERY
#define MODELNAME_X (2*FW-2)
#define PHASE_X (6*FW)
@@ -74,12 +74,12 @@
#define VBATTUNIT_Y (3*FH)
#define REBOOT_X (20*FW-3)
#define VSWITCH_X(i) (16 + 3*i)
#define VSWITCH_Y (DISPLAY_H-8)
#define VSWITCH_Y (LCD_H-8)
#define BAR_HEIGHT (BOX_WIDTH-1l)
#define TRIM_LH_X (DISPLAY_W*1/4+2)
#define TRIM_LH_X (LCD_W*1/4+2)
#define TRIM_LV_X 3
#define TRIM_RV_X (DISPLAY_W-4)
#define TRIM_RH_X (DISPLAY_W*3/4-2)
#define TRIM_RV_X (LCD_W-4)
#define TRIM_RH_X (LCD_W*3/4-2)
#endif
#define TRIM_LEN 27
@@ -90,9 +90,9 @@ void drawPotsBars()
{
// Optimization by Mike Blandford
uint8_t x, y, len ; // declare temporary variables
for (x=DISPLAY_W/2-5, y=NUM_STICKS; y<NUM_STICKS+NUM_POTS; x+=5, y++) {
for (x=LCD_W/2-5, y=NUM_STICKS; y<NUM_STICKS+NUM_POTS; x+=5, y++) {
len = ((calibratedStick[y]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
V_BAR(x, DISPLAY_H-8, len)
V_BAR(x, LCD_H-8, len)
}
}
@@ -163,19 +163,19 @@ void displayTrims(uint8_t phase)
void displaySliders()
{
for (uint8_t i=NUM_STICKS; i<NUM_STICKS+NUM_POTS; i++) {
xcoord_t x = (i%2 ? DISPLAY_W-5 : 3);
int8_t y = (i>NUM_STICKS+1 ? DISPLAY_H/2+1 : 1);
lcd_vline(x, y, DISPLAY_H/2-2);
lcd_vline(x+1, y, DISPLAY_H/2-2);
y += DISPLAY_H/2-4;
y -= ((calibratedStick[i]+RESX)*(DISPLAY_H/2-4)/(RESX*2)); // calculate once per loop
xcoord_t x = (i%2 ? LCD_W-5 : 3);
int8_t y = (i>NUM_STICKS+1 ? LCD_H/2+1 : 1);
lcd_vline(x, y, LCD_H/2-2);
lcd_vline(x+1, y, LCD_H/2-2);
y += LCD_H/2-4;
y -= ((calibratedStick[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop
lcd_vline(x-1, y, 2);
lcd_vline(x+2, y, 2);
}
}
#endif
#if LCD >= 212
#if LCD_W >= 212
void displayTimers()
{
// Main timer
@@ -273,7 +273,7 @@ void menuMainViewChannelsMonitor(uint8_t event)
void menuMainView(uint8_t event)
{
#if !defined(PCBX9D)
#if !defined(PCBX9D) && !defined(PCBACT)
uint8_t view = g_eeGeneral.view;
uint8_t view_base = view & 0x0f;
#endif
@@ -291,7 +291,7 @@ void menuMainView(uint8_t event)
killEvents(KEY_DOWN);
break;
#if !defined(PCBX9D)
#if !defined(PCBX9D) && !defined(PCBACT)
/* TODO if timer2 is OFF, it's possible to use this timer2 as in er9x...
case EVT_KEY_BREAK(KEY_MENU):
if (view_base == VIEW_TIMER2) {
@@ -393,7 +393,7 @@ void menuMainView(uint8_t event)
s_gvar_timer = 0;
}
#endif
#if LCD < 212
#if LCD_W < 212
else if (view == VIEW_TIMER2) {
resetTimer(1);
}
@@ -472,8 +472,8 @@ void menuMainView(uint8_t event)
uint8_t sw = 0;
for (uint8_t line=0; line<4; line++) {
for (uint8_t col=0; col<8; col++) {
uint8_t x = DISPLAY_W/2+7*FW+col*FW;
uint8_t y = DISPLAY_H/2-7+line*8;
uint8_t x = LCD_W/2+7*FW+col*FW;
uint8_t y = LCD_H/2-7+line*8;
lcd_putcAtt(x, y, sw>=9 ? 'A'+sw-9 : '1'+sw, SMLSIZE);
if (getSwitch(DSW(SW_SW1+sw), 0))
lcd_filled_rect(x-1, y-1, 6, 8);
@@ -517,7 +517,7 @@ void menuMainView(uint8_t event)
case VIEW_OUTPUTS_BARS:
#define WBAR2 (50/2)
x0 = i<4 ? DISPLAY_W/4+2 : DISPLAY_W*3/4-2;
x0 = i<4 ? LCD_W/4+2 : LCD_W*3/4-2;
y0 = 38+(i%4)*5;
uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2;
@@ -553,13 +553,13 @@ void menuMainView(uint8_t event)
for (uint8_t i=0; i<NUM_ROTARY_ENCODERS; i++) {
int16_t val = getRotaryEncoder(i);
int8_t len = limit((int16_t)0, (int16_t)(((val+1024) * BAR_HEIGHT) / 2048), (int16_t)BAR_HEIGHT);
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define V_BAR_W 5
V_BAR(DISPLAY_W/2-8+V_BAR_W*i, DISPLAY_H-8, len)
#else //EXTRA_ROTARY_ENCODERS
V_BAR(LCD_W/2-8+V_BAR_W*i, LCD_H-8, len)
#else
#define V_BAR_W 5
V_BAR(DISPLAY_W/2-3+V_BAR_W*i, DISPLAY_H-8, len)
#endif //EXTRA_ROTARY_ENCODERS
V_BAR(LCD_W/2-3+V_BAR_W*i, LCD_H-8, len)
#endif
}
#endif // PCBGRUVIN9X && ROTARY_ENCODERS
@@ -571,7 +571,7 @@ void menuMainView(uint8_t event)
lcd_vline(x-1, VSWITCH_Y-len, len);
lcd_vline(x, VSWITCH_Y-len, len);
}
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
for (uint8_t i=0; i<NUM_CSW; i++)
putsSwitches(2*FW-2 + (i/3)*(4*FW-2) + (i/3>1 ? 3*FW+6 : 0), 4*FH+1 + (i%3)*FH, 10+i, getSwitch(10+i, 0) ? INVERS : 0);
#elif defined(PCBGRUVIN9X)
+35 -37
View File
@@ -57,8 +57,8 @@ void menu_lcd_onoff(uint8_t x,uint8_t y, uint8_t value, LcdFlags attr)
void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr)
{
lcd_outdezAtt(DISPLAY_W,0,count,attr);
xcoord_t x = 1+DISPLAY_W-FW*(count>9 ? 3 : 2);
lcd_outdezAtt(LCD_W,0,count,attr);
xcoord_t x = 1+LCD_W-FW*(count>9 ? 3 : 2);
lcd_putcAtt(x,0,'/',attr);
lcd_outdezAtt(x,0,index+1,attr);
}
@@ -76,7 +76,7 @@ void displayScrollbar(xcoord_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_
}
#endif
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
int8_t scrollRE;
int16_t p1valdiff;
int8_t lastCursorMove;
@@ -128,7 +128,7 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
newval = !val;
}
#if defined (ROTARY_ENCODERS) || defined(NAVIGATION_POT1)
#if defined(ROTARY_ENCODER_NAVIGATION) || defined(NAVIGATION_POT1)
//change values based on P1
newval -= p1valdiff;
p1valdiff = 0;
@@ -203,7 +203,7 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow)
return check_simple(event, 0, 0, 0, maxrow);
}
#if defined(PCBX9D) || defined(PCBACT)
#if defined(PCBX9D)
void check_rotary_encoder(uint8_t & event)
{
if (lastCursorMove < -1 || event==EVT_KEY_REPT(KEY_MOVE_UP) || event==EVT_KEY_FIRST(KEY_MOVE_UP)) {
@@ -226,14 +226,14 @@ void check_rotary_encoder(uint8_t & event)
if (key==KEY_MOVE_UP || key==KEY_MOVE_DOWN)
event = 0;
}
#elif defined(ROTARY_ENCODERS)
#elif defined(ROTARY_ENCODER_NAVIGATION)
void check_rotary_encoder()
{
// check rotary encoder 1 if changed -> cursor down/up
static int16_t rePreviousValue;
if (g_eeGeneral.reNavigation) {
uint8_t re = g_eeGeneral.reNavigation - 1;
if (IS_RE_NAVIGATION_ENABLE()) {
uint8_t re = NAVIGATION_RE_IDX();
p1valdiff = 0;
int16_t reNewValue = (g_rotenc[re] / ROTARY_ENCODER_GRANULARITY);
scrollRE = rePreviousValue - reNewValue;
@@ -261,7 +261,7 @@ void title(const pm_char * s)
#define SCROLL_TH 64
#define SCROLL_POT1_TH 32
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
#define MAXCOL(row) ((horTab && row >= 0) ? pgm_read_byte(horTab+min(row, (maxrow_t)horTabMax)) : (const uint8_t)0)
#else
#define MAXCOL(row) (horTab ? pgm_read_byte(horTab+min(row, (maxrow_t)horTabMax)) : (const uint8_t)0)
@@ -270,13 +270,11 @@ void title(const pm_char * s)
#define INC(val,max) if(val<max) {val++;} else {val=0;}
#define DEC(val,max) if(val>0 ) {val--;} else {val=max;}
#if defined(PCBX9D)
#if defined(PCBX9D) || defined(PCBACT)
#define RE_NAV_ENTER (KEY_ENTER)
#define RE_NAV_ENABLE true
#define SCROLL(min, val, max) ((val) > (max) ? ((min) + (val) - (max) - 1) : ((val) < (min) ? ((max) - (min) + (val) + 1) : (val)))
#else
#define RE_NAV_ENTER (BTN_REa+g_eeGeneral.reNavigation-1)
#define RE_NAV_ENABLE g_eeGeneral.reNavigation
#define SCROLL(min, val, max) limit(min, val, max)
#endif
@@ -287,9 +285,9 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
uint8_t maxcol = MAXCOL(l_posVert);
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
#if defined(PCBX9D) || defined(PCBACT)
#if defined(PCBX9D)
if (!(s_warning || s_menu_count || s_editMode<0))
CHECK_ROTARY_ENCODER(event);
#else
@@ -302,7 +300,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
return false;
}
if (RE_NAV_ENABLE && event==EVT_KEY_BREAK(RE_NAV_ENTER)) {
if (IS_RE_NAVIGATION_ENABLE() && event==EVT_KEY_BREAK(RE_NAV_ENTER)) {
if (s_editMode > 0 && (maxcol & ZCHAR)) {
if (l_posHorz < maxcol-ZCHAR) {
l_posHorz++;
@@ -382,8 +380,8 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
return false;
}
#if defined(ROTARY_ENCODERS)
if (RE_NAV_ENABLE && s_editMode < 0)
#if defined(ROTARY_ENCODER_NAVIGATION)
if (IS_RE_NAVIGATION_ENABLE() && s_editMode < 0)
attr = INVERS|BLINK;
#endif
}
@@ -391,14 +389,14 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
s_noScroll = 0;
displayScreenIndex(curr, menuTabSize, attr);
#if LCD >= 212
if (maxrow > 7)
displayScrollbar(DISPLAY_W-1, FH, DISPLAY_H-FH, s_pgOfs, maxrow, 7);
#if LCD_W >= 212
if (maxrow > LCD_LINES-1)
displayScrollbar(LCD_W-1, FH, LCD_H-FH, s_pgOfs, maxrow, LCD_LINES-1);
#endif
}
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
else if (l_posVert < 0) {
lcd_putsAtt(DISPLAY_W-LEN_BACK*FW, 0, STR_BACK, INVERS);
lcd_putsAtt(LCD_W-LEN_BACK*FW, 0, STR_BACK, INVERS);
}
#endif
@@ -414,7 +412,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
l_posHorz = limit((int8_t)0, (int8_t)(l_posHorz - scrollLR), (int8_t)maxcol);
}
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
lastCursorMove = 0;
while (!s_editMode && scrollRE) {
if (scrollRE > 0) {
@@ -481,7 +479,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
case EVT_ENTRY:
l_posVert = 0;
l_posHorz = 0;
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
if (menuTab) {
s_editMode = -1;
break;
@@ -491,7 +489,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
s_editMode = -1;
break;
#endif
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ENTRY_UP:
s_editMode = 0;
break;
@@ -505,7 +503,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
popMenu();
break;
case EVT_KEY_BREAK(KEY_EXIT):
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
if (s_editMode==0)
s_editMode = -1;
else
@@ -547,8 +545,8 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
if (s_editMode>0) break;
do {
INC(l_posVert, maxrow);
} while(MAXCOL(l_posVert) == (uint8_t)-1);
#if defined(ROTARY_ENCODERS)
} while (MAXCOL(l_posVert) == (uint8_t)-1);
#if defined(ROTARY_ENCODER_NAVIGATION)
s_editMode = 0;
#endif
l_posHorz = min(l_posHorz, MAXCOL(l_posVert));
@@ -557,7 +555,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
if (l_posVert==0) break;
// no break
case EVT_KEY_FIRST(KEY_UP): //dec
if(s_editMode>0)break;
if (s_editMode>0)break;
do {
DEC(l_posVert, maxrow);
} while(MAXCOL(l_posVert) == (uint8_t)-1);
@@ -566,7 +564,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
#endif
}
uint8_t max = menuTab ? 7 : 6;
uint8_t max = menuTab ? LCD_LINES-1 : LCD_LINES-2;
if (l_posVert<1) s_pgOfs=0;
else if (l_posVert-s_pgOfs>max) s_pgOfs = l_posVert-max;
else if (l_posVert-s_pgOfs<1) s_pgOfs = l_posVert-1;
@@ -632,8 +630,8 @@ const pm_char * s_global_warning = 0;
void displayBox()
{
lcd_filled_rect(10, 16, DISPLAY_W-20, 40, SOLID, ERASE);
lcd_rect(10, 16, DISPLAY_W-20, 40);
lcd_filled_rect(10, 16, LCD_W-20, 40, SOLID, ERASE);
lcd_rect(10, 16, LCD_W-20, 40);
lcd_puts(16, 3*FH, s_warning);
// could be a place for a s_warning_info
}
@@ -731,12 +729,12 @@ int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max,
}
#endif
#if LCD >= 212
#if LCD_W >= 212
#define MENU_X 30
#define MENU_W DISPLAY_W-60
#define MENU_W LCD_W-60
#else
#define MENU_X 10
#define MENU_W DISPLAY_W-20
#define MENU_W LCD_W-20
#endif
#if defined(SDCARD)
@@ -817,9 +815,9 @@ void drawStatusLine()
statusLineTime = 0;
}
lcd_filled_rect(0, 8*FH-statusLineHeight, DISPLAY_W, 8, SOLID, ERASE);
lcd_filled_rect(0, 8*FH-statusLineHeight, LCD_W, 8, SOLID, ERASE);
lcd_putsAtt(5, 8*FH+1-statusLineHeight, statusLineMsg, BSS);
lcd_filled_rect(0, 8*FH-statusLineHeight, DISPLAY_W, 8, SOLID);
lcd_filled_rect(0, 8*FH-statusLineHeight, LCD_W, 8, SOLID);
}
}
+14 -13
View File
@@ -48,7 +48,7 @@ typedef void (*MenuFuncP)(uint8_t event);
void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
#if LCD >= 212
#if LCD_W >= 212
#define MENUS_SCROLLBAR_WIDTH 2
#else
#define MENUS_SCROLLBAR_WIDTH 0
@@ -96,28 +96,29 @@ void menuModelCustomFunctions(uint8_t event);
void menuStatisticsView(uint8_t event);
void menuStatisticsDebug(uint8_t event);
#if defined(PCBX9D)
#if defined(ROTARY_ENCODER_NAVIGATION)
extern int8_t scrollRE;
extern int16_t p1valdiff;
extern int8_t lastCursorMove;
#elif defined(NAVIGATION_POT1)
extern int16_t p1valdiff;
#else
#define p1valdiff 0
#endif
#if defined(PCBX9D) || defined(PCBACT)
#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)
#elif defined(ROTARY_ENCODERS)
extern int8_t scrollRE;
extern int16_t p1valdiff;
extern int8_t lastCursorMove;
#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))
#else
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (0)
#define IS_RE_NAVIGATION_EVT(event) (0)
#if defined(NAVIGATION_POT1)
extern int16_t p1valdiff;
#else
#define p1valdiff 0
#endif
#endif
extern int8_t checkIncDec_Ret; // global helper vars
@@ -147,10 +148,10 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
#define CHECK_INCDEC_GENVAR(event, var, min, max) \
var = checkIncDecGen(event,var,min,max)
#if defined(PCBX9D) || defined(PCBACT)
#if defined(PCBX9D)
void check_rotary_encoder(uint8_t & event);
#define CHECK_ROTARY_ENCODER(event) check_rotary_encoder(event)
#elif defined(ROTARY_ENCODERS)
#elif defined(ROTARY_ENCODER_NAVIGATION)
void check_rotary_encoder();
#define CHECK_ROTARY_ENCODER(event) check_rotary_encoder()
#endif
@@ -158,7 +159,7 @@ void check_rotary_encoder();
// Menus related stuff ...
#if defined(SDCARD)
#define maxrow_t int16_t
#elif defined(ROTARY_ENCODERS)
#elif defined(ROTARY_ENCODER_NAVIGATION)
#define maxrow_t int8_t
#else
#define maxrow_t uint8_t
+100 -100
View File
@@ -35,7 +35,7 @@
#include "open9x.h"
#define WCHART 32
#define X0 (DISPLAY_W-WCHART-2)
#define X0 (LCD_W-WCHART-2)
#define Y0 32
enum EnumTabModel {
@@ -244,7 +244,7 @@ void menuModelSelect(uint8_t event)
if (s_copyMode
/* TODO how is it possible? || !eeModelExists(g_eeGeneral.currModel)*/
#if defined(PCBX9D)
#if defined(PCBX9D) || defined(PCBACT)
|| s_editMode >= 0
#endif
) {
@@ -256,14 +256,14 @@ void menuModelSelect(uint8_t event)
if (!check_submenu_simple(_event_, MAX_MODELS-1)) return;
#if defined(PCBX9D) || defined(PCBACT)
if (m_posVert < 0) m_posVert = MAX_MODELS-1;
#elif defined(ROTARY_ENCODERS)
#elif defined(ROTARY_ENCODER_NAVIGATION)
if (m_posVert < 0) m_posVert = 0;
#endif
if (s_editMode > 0) s_editMode = 0;
#if !defined(CPUARM)
if (event
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
|| oldSub != m_posVert
#endif
) {
@@ -276,7 +276,7 @@ void menuModelSelect(uint8_t event)
int8_t sub = m_posVert;
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
if (scrollRE > 0 && s_editMode < 0) {
chainMenu(menuModelSetup);
return;
@@ -304,7 +304,7 @@ void menuModelSelect(uint8_t event)
sub = m_posVert = (s_copyMode == MOVE_MODE || s_copySrcRow<0) ? (MAX_MODELS+sub+s_copyTgtOfs) % MAX_MODELS : s_copySrcRow;
s_copyMode = 0;
}
#if defined(PCBX9D)
#if defined(PCBX9D) || defined(PCBACT)
else {
m_posVert = sub = g_eeGeneral.currModel;
s_editMode = -1;
@@ -443,7 +443,7 @@ void menuModelSelect(uint8_t event)
}
#if defined(PCBX9D)
#if defined(PCBX9D) || defined(PCBACT)
lcd_puts(27*FW-(LEN_FREE-4)*FW, 0, STR_FREE);
if (refresh) reusableBuffer.models.eepromfree = EeFsGetFree();
lcd_outdezAtt(20*FW, 0, reusableBuffer.models.eepromfree, 0);
@@ -454,7 +454,7 @@ void menuModelSelect(uint8_t event)
lcd_outdezAtt(17*FW, 0, reusableBuffer.models.eepromfree, 0);
#endif
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? ((IS_RE_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0);
#else
displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? INVERS : 0);
@@ -463,7 +463,7 @@ void menuModelSelect(uint8_t event)
if (sub-s_pgOfs < 1) s_pgOfs = max(0, sub-1);
else if (sub-s_pgOfs > 5) s_pgOfs = min(MAX_MODELS-7, sub-4);
for (uint8_t i=0; i<7; i++) {
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y=(i+1)*FH+1;
uint8_t k=i+s_pgOfs;
lcd_outdezNAtt(3*FW+2, y, k+1, LEADING0+((!s_copyMode && sub==k) ? INVERS : 0), 2);
@@ -472,7 +472,7 @@ void menuModelSelect(uint8_t event)
if (k == sub) {
if (s_copyMode == COPY_MODE) {
k = s_copySrcRow;
lcd_putc(DISPLAY_W-FW, y, '+');
lcd_putc(LCD_W-FW, y, '+');
}
else {
k = sub + s_copyTgtOfs;
@@ -502,8 +502,8 @@ void menuModelSelect(uint8_t event)
}
if (s_copyMode && (pgofs_t)sub==i+s_pgOfs) {
lcd_filled_rect(9, y, DISPLAY_W-1-9, 7);
lcd_rect(8, y-1, DISPLAY_W-1-7, 9, s_copyMode == COPY_MODE ? SOLID : DOTTED);
lcd_filled_rect(9, y, LCD_W-1-9, 7);
lcd_rect(8, y-1, LCD_W-1-7, 9, s_copyMode == COPY_MODE ? SOLID : DOTTED);
}
}
@@ -648,10 +648,10 @@ enum menuModelSetupItems {
#define FIELD_TIMER_MAX 2
#endif
#if LCD >= 212
#define MODEL_SETUP_2ND_COLUMN (DISPLAY_W-17*FW-MENUS_SCROLLBAR_WIDTH)
#if LCD_W >= 212
#define MODEL_SETUP_2ND_COLUMN (LCD_W-17*FW-MENUS_SCROLLBAR_WIDTH)
#else
#define MODEL_SETUP_2ND_COLUMN (DISPLAY_W-11*FW-MENUS_SCROLLBAR_WIDTH)
#define MODEL_SETUP_2ND_COLUMN (LCD_W-11*FW-MENUS_SCROLLBAR_WIDTH)
#endif
void menuModelSetup(uint8_t event)
@@ -663,7 +663,7 @@ void menuModelSetup(uint8_t event)
}
#endif
#if LCD >= 212
#if LCD_W >= 212
lcd_outdezNAtt(13*FW, 0, g_eeGeneral.currModel+1, INVERS+LEADING0, 2);
#else
lcd_outdezNAtt(7*FW, 0, g_eeGeneral.currModel+1, INVERS+LEADING0, 2);
@@ -678,11 +678,11 @@ void menuModelSetup(uint8_t event)
MENU(STR_MENUSETUP, menuTabModel, e_Model, ((protocol<=PROTO_PPMSIM||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX), {0,ZCHAR|(sizeof(g_model.name)-1),IF_PCBX9D(0) FIELD_TIMER_MAX,FIELD_TIMER_MAX,0,0,0,0,0,0,0,NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1,1,2});
uint8_t sub = m_posVert - 1;
uint8_t sub = m_posVert - 1;
int8_t editMode = s_editMode;
for (uint8_t i=0; i<7; i++) {
uint8_t y = 1*FH + i*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y = 1 + 1*FH + i*FH;
uint8_t k = i+s_pgOfs;
uint8_t blink = ((editMode>0) ? BLINK|INVERS : INVERS);
uint8_t attr = (sub == k ? blink : 0);
@@ -967,8 +967,8 @@ static uint8_t s_currIdx;
#define MIXES_2ND_COLUMN (11*FW)
#endif
#if LCD >= 212
#define EXPO_ONE_2ND_COLUMN (DISPLAY_W - 88)
#if LCD_W >= 212
#define EXPO_ONE_2ND_COLUMN (LCD_W - 88)
#define EXPO_ONE_FP_WIDTH (9*FW)
#else
#define EXPO_ONE_2ND_COLUMN (7*FW+2)
@@ -978,8 +978,8 @@ static uint8_t s_currIdx;
uint8_t editDelay(const uint8_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay)
{
lcd_putsLeft(y, str);
lcd_outdezAtt(MIXES_2ND_COLUMN, y, 5*delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR(event, delay, 0, MAX_DELAY);
lcd_outdezAtt(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR(event, delay, 0, DELAY_MAX);
return delay;
}
@@ -1056,10 +1056,10 @@ void menuModelPhaseOne(uint8_t event)
TITLE(STR_MENUFLIGHTPHASE);
#define PHASE_ONE_FIRST_LINE (1*FH)
#define PHASE_ONE_FIRST_LINE (1+1*FH)
#else
SUBMENU(STR_MENUFLIGHTPHASE, 3 + (s_currIdx==0 ? 0 : 2 + (bool)NUM_ROTARY_ENCODERS), {ZCHAR|(sizeof(phase->name)-1), 0, 3, IF_ROTARY_ENCODERS(NUM_ROTARY_ENCODERS-1) 0/*, 0*/});
#define PHASE_ONE_FIRST_LINE (2*FH)
#define PHASE_ONE_FIRST_LINE (1+1*FH)
#endif
int8_t sub = m_posVert;
@@ -1068,8 +1068,8 @@ void menuModelPhaseOne(uint8_t event)
#if defined(GVARS) && !defined(CPUM64)
if (s_currIdx == 0 && sub>=ITEM_MODEL_PHASE_SWITCH) sub += ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH;
for (uint8_t k=0; k<7; k++) {
uint8_t y = (k+1) * FH;
for (uint8_t k=0; k<LCD_LINES-1; k++) {
uint8_t y = 1 + (k+1)*FH;
int8_t i = k + s_pgOfs;
if (s_currIdx == 0 && i>=ITEM_MODEL_PHASE_SWITCH) i += ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH;
uint8_t attr = (sub==i ? (editMode>0 ? BLINK|INVERS : INVERS) : 0);
@@ -1101,13 +1101,13 @@ void menuModelPhaseOne(uint8_t event)
}
break;
#if defined(ROTARY_ENCODERS) && NUM_ROTARY_ENCODERS > 0
#if ROTARY_ENCODERS > 0
case ITEM_MODEL_PHASE_ROTARY_ENCODERS:
lcd_putsLeft(y, STR_ROTARY_ENCODER);
for (uint8_t t=0; t<NUM_ROTARY_ENCODERS; t++) {
putsRotaryEncoderMode(MIXES_2ND_COLUMN+(t*FW), y, s_currIdx, t, (attr && m_posHorz==t) ? ((editMode>0) ? BLINK|INVERS : INVERS) : 0);
if (attr && m_posHorz==t && ((editMode>0) || p1valdiff)) {
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
int16_t v;
if(t < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
v = phaseaddress(s_currIdx)->rotaryEncoders[t];
@@ -1120,7 +1120,7 @@ void menuModelPhaseOne(uint8_t event)
v = checkIncDec(event, v, ROTARY_ENCODER_MAX, ROTARY_ENCODER_MAX+MAX_PHASES-1, EE_MODEL);
if (checkIncDec_Ret) {
if (v == ROTARY_ENCODER_MAX) v = 0;
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
if (t < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
phaseaddress(s_currIdx)->rotaryEncoders[t] = v;
else
@@ -1222,30 +1222,30 @@ void menuModelPhasesAll(uint8_t event)
uint8_t att;
for (uint8_t i=0; i<MAX_PHASES; i++) {
#if defined(CPUARM)
int8_t y = (1+i-s_pgOfs)*FH;
if (y<1*FH || y>7*FH) continue;
int8_t y = 1 + (1+i-s_pgOfs)*FH;
if (y<1*FH+1 || y>(LCD_LINES-1)*FH+1) continue;
#else
uint8_t y=(i+1)*FH;
uint8_t y = 1 + (i+1)*FH;
#endif
att = i==sub ? INVERS : 0;
att = (i==sub ? INVERS : 0);
PhaseData *p = phaseaddress(i);
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
putsFlightPhase(0, y, i+1, att|CONDENSED|(getFlightPhase()==i ? BOLD : 0));
#else //EXTRA_ROTARY_ENCODERS
#else
putsFlightPhase(0, y, i+1, att|(getFlightPhase()==i ? BOLD : 0));
#endif //EXTRA_ROTARY_ENCODERS
#endif
#if defined(ROTARY_ENCODERS)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define NAME_OFS (-4-12)
#define SWITCH_OFS (-FW/2-2-13)
#define TRIMS_OFS (-FW/2-4-15)
#define ROTARY_ENC_OFS (0)
#else //!EXTRA_ROTARY_ENCODERS
#else
#define NAME_OFS (-4)
#define SWITCH_OFS (-FW/2-2)
#define TRIMS_OFS (-FW/2-4)
#define ROTARY_ENC_OFS (2)
#endif //EXTRA_ROTARY_ENCODERS
#endif
#else
#define NAME_OFS 0
#define SWITCH_OFS (FW/2)
@@ -1266,24 +1266,24 @@ void menuModelPhasesAll(uint8_t event)
}
#endif
}
#if LCD >= 212
#if LCD_W >= 212
if (p->fadeIn || p->fadeOut) {
lcd_outdezAtt(24*FW, y, 5*p->fadeIn, PREC1|LEFT);
lcd_outdezAtt(24*FW, y, (10/SLOW_STEP)*p->fadeIn, PREC1|LEFT);
lcd_putc(lcdLastPos, y, '/');
lcd_outdezAtt(lcdLastPos+FW, y, 5*p->fadeOut, PREC1|LEFT);
lcd_outdezAtt(lcdLastPos+FW, y, (10/SLOW_STEP)*p->fadeOut, PREC1|LEFT);
}
#else
if (p->fadeIn || p->fadeOut)
lcd_putc(DISPLAY_W-FW-MENUS_SCROLLBAR_WIDTH, y, (p->fadeIn && p->fadeOut) ? '*' : (p->fadeIn ? 'I' : 'O'));
lcd_putc(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, (p->fadeIn && p->fadeOut) ? '*' : (p->fadeIn ? 'I' : 'O'));
#endif
}
#if defined(CPUARM)
if (s_pgOfs != MAX_PHASES-6) return;
if (s_pgOfs != MAX_PHASES-(LCD_LINES-2)) return;
#endif
lcd_putsLeft(7*FH+1, STR_CHECKTRIMS);
putsFlightPhase(OFS_CHECKTRIMS, 7*FH+1, s_perout_flight_phase+1);
lcd_putsLeft((LCD_LINES-1)*FH+1, STR_CHECKTRIMS);
putsFlightPhase(OFS_CHECKTRIMS, (LCD_LINES-1)*FH+1, s_perout_flight_phase+1);
if (sub==MAX_PHASES && !trimsCheckTimer) {
lcd_status_line();
}
@@ -1311,7 +1311,7 @@ void menuModelHeli(uint8_t event)
uint8_t sub = m_posVert - 1;
for (uint8_t i=0; i<6; i++) {
uint8_t y = 1*FH + i*FH;
uint8_t y = 1 + 1*FH + i*FH;
uint8_t attr = (sub == i ? INVERS : 0);
switch(i) {
@@ -1367,14 +1367,14 @@ int16_t curveFn(int16_t x)
void DrawCurve(FnFuncP fn, uint8_t offset=0)
{
lcd_vlineStip(X0-offset, 0, DISPLAY_H, 0xee);
lcd_vlineStip(X0-offset, 0, LCD_H, 0xee);
lcd_hlineStip(X0-WCHART-offset, Y0, WCHART*2, 0xee);
uint8_t prev_yv = 255;
for (int8_t xv=-WCHART+1; xv<=WCHART; xv++) {
uint16_t yv = (RESX + fn(xv * (RESX/WCHART))) / 2;
yv = (DISPLAY_H-1) - yv * (DISPLAY_H-1) / RESX;
yv = (LCD_H-1) - yv * (LCD_H-1) / RESX;
if (prev_yv != 255) {
if (abs((int8_t)yv-prev_yv) <= 1)
lcd_plot(X0+xv-offset, prev_yv, FORCE);
@@ -1522,7 +1522,7 @@ void menuModelCurveOne(uint8_t event)
for (uint8_t i=0; i<crv.points; i++) {
uint8_t xx = X0-1-WCHART+i*WCHART/(crv.points/2);
uint8_t yy = (DISPLAY_H-1) - (100 + crv.crv[i]) * (DISPLAY_H-1) / 200;
uint8_t yy = (LCD_H-1) - (100 + crv.crv[i]) * (LCD_H-1) / 200;
if (crv.custom && i>0 && i<crv.points-1)
xx = X0-1-WCHART + (100 + (100 + crv.crv[crv.points+i-1]) * (2*WCHART)) / 200;
@@ -1759,7 +1759,7 @@ void menuModelExpoOne(uint8_t event)
int8_t sub = m_posVert;
uint8_t y = FH;
uint8_t y = FH+1;
for (uint8_t i=0; i<EXPO_FIELD_MAX+1; i++) {
uint8_t attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
@@ -1823,11 +1823,11 @@ void menuModelExpoOne(uint8_t event)
int16_t x512 = calibratedStick[ed->chn];
int16_t y512 = expoFn(x512);
lcd_outdezAtt(DISPLAY_W-8, 6*FH, x512*25/256, 0);
lcd_outdezAtt(DISPLAY_W-8-6*FW, 1*FH, y512*25/256, 0);
lcd_outdezAtt(LCD_W-8, 6*FH, x512*25/256, 0);
lcd_outdezAtt(LCD_W-8-6*FW, 1*FH, y512*25/256, 0);
x512 = X0+x512/(RESXu/WCHART);
y512 = (DISPLAY_H-1) - (uint16_t)((y512+RESX)/2) * (DISPLAY_H-1) / RESX;
y512 = (LCD_H-1) - (uint16_t)((y512+RESX)/2) * (LCD_H-1) / RESX;
lcd_vline(x512, y512-3,3*2+1);
lcd_hline(x512-3, y512,3*2+1);
@@ -1853,7 +1853,7 @@ enum MixFields {
void menuModelMixOne(uint8_t event)
{
#if defined(PCBX9D) || defined(PCBACT)
#if defined(PCBX9D)
if (event == EVT_KEY_LONG(KEY_PAGE)) {
pushMenu(menuChannelsMonitor);
killEvents(event);
@@ -1881,8 +1881,8 @@ void menuModelMixOne(uint8_t event)
int8_t sub = m_posVert;
int8_t editMode = s_editMode;
for (uint8_t k=0; k<7; k++) {
uint8_t y = (k+1) * FH;
for (uint8_t k=0; k<LCD_LINES-1; k++) {
uint8_t y = 1 + (k+1)*FH;
int8_t i = k + s_pgOfs;
uint8_t attr = (sub==i ? (editMode>0 ? BLINK|INVERS : INVERS) : 0);
switch(i) {
@@ -2149,19 +2149,19 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
for (uint8_t ch=1; ch<=(expo ? NUM_STICKS : NUM_CHNOUT); ch++) {
void *pointer = NULL; MixData * &md = (MixData * &)pointer; ExpoData * &ed = (ExpoData * &)pointer;
uint8_t y = (cur-s_pgOfs)*FH;
uint8_t y = 1+(cur-s_pgOfs)*FH;
if (expo ? (i<MAX_EXPOS && (ed=expoaddress(i))->chn+1 == ch && ed->mode) : (i<MAX_MIXERS && (md=mixaddress(i))->srcRaw && md->destCh+1 == ch)) {
if (s_pgOfs < cur && cur-s_pgOfs < 8) {
if (s_pgOfs < cur && cur-s_pgOfs < LCD_LINES) {
if (expo)
putsChnRaw(0, (cur-s_pgOfs)*FH, ch, 0);
putsChnRaw(0, y, ch, 0);
else
putsChn(0, (cur-s_pgOfs)*FH, ch, 0); // show CHx
putsChn(0, y, ch, 0); // show CHx
}
uint8_t mixCnt = 0;
do {
if (s_copyMode) {
if (s_copyMode == MOVE_MODE && s_pgOfs < cur && cur-s_pgOfs < 8 && s_copySrcCh == ch && s_copyTgtOfs != 0 && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
lcd_rect(expo ? 18 : 22, y-1, expo ? DISPLAY_W-18 : DISPLAY_W-22, 9, DOTTED);
lcd_rect(expo ? 18 : 22, y-1, expo ? LCD_W-18 : LCD_W-22, 9, DOTTED);
cur++; y+=FH;
}
if (s_currIdx == i) {
@@ -2185,9 +2185,9 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
#if defined(CPUARM)
if (ed->name[0]) {
putsSwitches(11*FW, y, ed->swtch, 0);
lcd_putsnAtt(DISPLAY_W-sizeof(ed->name)*FW-MENUS_SCROLLBAR_WIDTH, y, ed->name, sizeof(ed->name), ZCHAR | (isExpoActive(i) ? BOLD : 0));
lcd_putsnAtt(LCD_W-sizeof(ed->name)*FW-MENUS_SCROLLBAR_WIDTH, y, ed->name, sizeof(ed->name), ZCHAR | (isExpoActive(i) ? BOLD : 0));
}
#if LCD < 212
#if LCD_W < 212
else
#endif
#endif
@@ -2206,9 +2206,9 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
#if defined(CPUARM)
if (md->name[0]) {
lcd_putsnAtt(DISPLAY_W-sizeof(md->name)*FW-MENUS_SCROLLBAR_WIDTH, y, md->name, sizeof(md->name), ZCHAR | (isMixActive(i) ? BOLD : 0));
lcd_putsnAtt(LCD_W-sizeof(md->name)*FW-MENUS_SCROLLBAR_WIDTH, y, md->name, sizeof(md->name), ZCHAR | (isMixActive(i) ? BOLD : 0));
}
#if LCD < 212
#if LCD_W < 212
else
#endif
#endif
@@ -2232,18 +2232,18 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
if (s_copyMode) {
if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
/* draw a border around the raw on selection mode (copy/move) */
lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (DISPLAY_W-EXPO_LINE_SELECT_POS) : (DISPLAY_W-22), 9, s_copyMode == COPY_MODE ? SOLID : DOTTED);
lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, s_copyMode == COPY_MODE ? SOLID : DOTTED);
}
if (cur == sub) {
/* invert the raw when it's the current one */
lcd_filled_rect(expo ? EXPO_LINE_SELECT_POS+1 : 23, y, expo ? (DISPLAY_W-EXPO_LINE_SELECT_POS-2) : (DISPLAY_W-24), 7);
lcd_filled_rect(expo ? EXPO_LINE_SELECT_POS+1 : 23, y, expo ? (LCD_W-EXPO_LINE_SELECT_POS-2) : (LCD_W-24), 7);
}
}
}
cur++; y+=FH; mixCnt++; i++; if (expo) ed++; else md++;
} while (expo ? (i<MAX_EXPOS && ed->chn+1 == ch && ed->mode) : (i<MAX_MIXERS && md->srcRaw && md->destCh+1 == ch));
if (s_copyMode == MOVE_MODE && s_pgOfs < cur && cur-s_pgOfs < 8 && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? DISPLAY_W-EXPO_LINE_SELECT_POS : DISPLAY_W-22, 9, DOTTED);
if (s_copyMode == MOVE_MODE && s_pgOfs < cur && cur-s_pgOfs < LCD_LINES && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? LCD_W-EXPO_LINE_SELECT_POS : LCD_W-22, 9, DOTTED);
cur++; y+=FH;
}
}
@@ -2256,13 +2256,13 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
attr = INVERS;
}
}
if (s_pgOfs < cur && cur-s_pgOfs < 8) {
if (s_pgOfs < cur && cur-s_pgOfs < LCD_LINES) {
if (expo)
putsChnRaw(0, y, ch, attr);
else
putsChn(0, y, ch, attr); // show CHx
if (s_copyMode == MOVE_MODE && s_copySrcCh == ch) {
lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (DISPLAY_W-EXPO_LINE_SELECT_POS) : (DISPLAY_W-22), 9, DOTTED);
lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, DOTTED);
}
}
cur++; y+=FH;
@@ -2279,7 +2279,7 @@ void menuModelExposAll(uint8_t event)
void menuModelMixAll(uint8_t event)
{
#if defined(PCBX9D) || defined(PCBACT)
#if defined(PCBX9D)
if (event == EVT_KEY_LONG(KEY_PAGE)) {
pushMenu(menuChannelsMonitor);
killEvents(event);
@@ -2370,8 +2370,8 @@ void menuModelLimits(uint8_t event)
AUDIO_WARNING2();
}
for (uint8_t i=0; i<7; i++) {
uint8_t y = (i+1)*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y = 1 + (i+1)*FH;
uint8_t k = i+s_pgOfs;
if (k==NUM_CHNOUT) {
@@ -2391,7 +2391,7 @@ void menuModelLimits(uint8_t event)
LimitData *ld = limitaddress(k) ;
#if LCD >= 212 || !defined(PPM_CENTER_ADJUSTABLE)
#if LCD_W >= 212 || !defined(PPM_CENTER_ADJUSTABLE)
int16_t v = (ld->revert) ? -ld->offset : ld->offset;
char swVal = '-'; // '-', '<', '>'
if((g_chans512[k] - v) > 50) swVal = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim!
@@ -2481,7 +2481,7 @@ void menuModelLimits(uint8_t event)
#endif
#if defined(PPM_LIMITS_SYMETRICAL)
case ITEM_LIMITS_SYMETRICAL:
lcd_putcAtt(DISPLAY_W-FW, y, ld->symetrical ? '=' : '^', attr);
lcd_putcAtt(LCD_W-FW, y, ld->symetrical ? '=' : '^', attr);
if (active) {
CHECK_INCDEC_MODELVAR(event, ld->symetrical, 0, 1);
}
@@ -2509,7 +2509,7 @@ void menuModelCurvesAll(uint8_t event)
SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVES);
#endif
int8_t sub = m_posVert - 1;
int8_t sub = m_posVert - 1;
switch (event) {
#if defined(ROTARY_ENCODERS)
@@ -2530,8 +2530,8 @@ void menuModelCurvesAll(uint8_t event)
break;
}
for (uint8_t i = 0; i < 7; i++) {
uint8_t y = FH + i*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y = 1 + FH + i*FH;
uint8_t k = i + s_pgOfs;
uint8_t attr = (sub == k ? INVERS : 0);
#if defined(GVARS) && defined(CPUM64)
@@ -2577,10 +2577,10 @@ void menuModelCustomSwitchOne(uint8_t event)
putsSwitches(14*FW, 0, sw, (getSwitch(sw, 0) ? BOLD : 0));
SIMPLE_SUBMENU_NOTITLE(CSW_FIELD_COUNT);
int8_t sub = m_posVert;
int8_t sub = m_posVert;
for (uint8_t k=0; k<7; k++) {
uint8_t y = (k+2) * FH;
for (uint8_t k=0; k<LCD_LINES-1; k++) {
uint8_t y = 1 + (k+2)*FH;
uint8_t i = k + s_pgOfs;
uint8_t attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
uint8_t cstate = CS_STATE(cs->func);
@@ -2701,8 +2701,8 @@ void menuModelCustomSwitches(uint8_t event)
break;
}
for (uint8_t i=0; i<7; i++) {
y = (i+1)*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
y = 1 + (i+1)*FH;
k = i+s_pgOfs;
CustomSwData * cs = cswaddress(k);
@@ -2751,8 +2751,8 @@ void menuModelCustomSwitches(uint8_t event)
uint8_t k = 0;
int8_t sub = m_posVert - 1;
for (uint8_t i=0; i<7; i++) {
y = (i+1)*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
y = 1 + (i+1)*FH;
k = i+s_pgOfs;
uint8_t attr = (sub==k ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
CustomSwData * cs = cswaddress(k);
@@ -2827,7 +2827,7 @@ void menuModelCustomSwitches(uint8_t event)
}
#endif
#if LCD >= 212
#if LCD_W >= 212
#define MODEL_CUSTOM_FUNC_2ND_COLUMN (6*FW-2)
#define MODEL_CUSTOM_FUNC_3RD_COLUMN (20*FW+2)
#define MODEL_CUSTOM_FUNC_4TH_COLUMN (25*FW)
@@ -2852,13 +2852,13 @@ void menuModelCustomFunctions(uint8_t event)
MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_FSW+1, {0, 3/*repeated*/});
uint8_t y = 0;
uint8_t y;
uint8_t k = 0;
int8_t sub = m_posVert - 1;
for (uint8_t i=0; i<7; i++) {
y=(i+1)*FH;
k=i+s_pgOfs;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
y = 1 + (i+1)*FH;
k = i+s_pgOfs;
if(k==NUM_CHNOUT) break;
FuncSwData *sd = &g_model.funcSw[k];
for (uint8_t j=0; j<4; j++) {
@@ -3106,8 +3106,8 @@ enum menuModelTelemetryItems {
#endif
#ifdef FRSKY
#if LCD >= 212
#define TELEM_COL2 (DISPLAY_W-17*FW-MENUS_SCROLLBAR_WIDTH)
#if LCD_W >= 212
#define TELEM_COL2 (LCD_W-17*FW-MENUS_SCROLLBAR_WIDTH)
#elif defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_CZ)
#define TELEM_COL2 (9*FW)
#else
@@ -3132,8 +3132,8 @@ void menuModelTelemetry(uint8_t event)
break;
}
for (uint8_t i=0; i<7; i++) {
uint8_t y = 1*FH + i*FH;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y = 1 + 1*FH + i*FH;
uint8_t k = i + s_pgOfs;
uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
uint8_t attr = (sub == k ? blink : 0);
@@ -3423,10 +3423,10 @@ void menuModelTemplates(uint8_t event)
}
}
uint8_t y = 1*FH;
uint8_t y = 1 + 1*FH;
uint8_t k = 0;
for (uint8_t i=0; i<7 && k<TMPL_COUNT; i++) {
k=i+s_pgOfs;
for (uint8_t i=0; i<LCD_LINES-1 && k<TMPL_COUNT; i++) {
k = i+s_pgOfs;
lcd_outdezNAtt(3*FW, y, k, (sub==k ? INVERS : 0)|LEADING0, 2);
lcd_putsiAtt(4*FW, y, STR_VTEMPLATES, k, (sub==k ? INVERS : 0));
y+=FH;
+3 -3
View File
@@ -50,16 +50,16 @@ void menuChannelsMonitor(uint8_t event)
for (uint8_t col=0; col<4; col++) {
uint8_t x = col*DISPLAY_W/4;
uint8_t x = col*LCD_W/4;
// Column title
lcd_outdezNAtt(col==0 ? 28 : (col == 1 ? 81 : x+DISPLAY_W/8-5*FWNUM/2+9), 1*FH+1, ch+1, LEFT|SMLSIZE);
lcd_outdezNAtt(col==0 ? 28 : (col == 1 ? 81 : x+LCD_W/8-5*FWNUM/2+9), 1*FH+1, ch+1, LEFT|SMLSIZE);
lcd_putcAtt(lcdLastPos-1, 1*FH+1, '-', SMLSIZE);
lcd_outdezNAtt(lcdLastPos+FW-1, 1*FH+1, ch+8, LEFT|SMLSIZE);
// Column separator
if (col != 0)
lcd_vline(x, FH, DISPLAY_H-FH);
lcd_vline(x, FH, LCD_H-FH);
// Channels
for (uint8_t line=0; line<8; line++) {
+14 -10
View File
@@ -81,7 +81,7 @@ PACK(typedef struct t_FrSkyRSSIAlarm {
int8_t value:6;
}) FrSkyRSSIAlarm;
#if LCD >= 212
#if defined(PCBX9D) || defined(PCBACT)
enum MainViews {
VIEW_INPUTS,
VIEW_SWITCHES,
@@ -256,8 +256,10 @@ PACK(typedef struct t_LimitData {
#define MODE_CURVE 1
#if defined(CPUARM)
#define MAX_DELAY 60 /* 30 seconds */
#define MAX_SLOW 60 /* 30 seconds */
#define DELAY_STEP 10
#define SLOW_STEP 10
#define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */
#define SLOW_MAX (25*SLOW_STEP) /* 25 seconds */
PACK(typedef struct t_MixData {
uint8_t destCh;
uint16_t phases;
@@ -279,8 +281,10 @@ PACK(typedef struct t_MixData {
char name[LEN_EXPOMIX_NAME];
}) MixData;
#else
#define MAX_DELAY 15 /* 7.5 seconds */
#define MAX_SLOW 15 /* 7.5 seconds */
#define DELAY_STEP 2
#define SLOW_STEP 2
#define DELAY_MAX 15 /* 7.5 seconds */
#define SLOW_MAX 15 /* 7.5 seconds */
PACK(typedef struct t_MixData {
uint8_t destCh:4; // 0, 1..NUM_CHNOUT
uint8_t curveMode:1; // O=curve, 1=differential
@@ -561,12 +565,12 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data
#define ROTARY_ENCODER_MAX 1024
#if defined(PCBACT)
#define NUM_ROTARY_ENCODERS 1
#define NUM_ROTARY_ENCODERS 0
#define ROTARY_ENCODER_ARRAY_EXTRA
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[1];
#elif defined(PCBX9D)
#define NUM_ROTARY_ENCODERS_EXTRA 0
#define NUM_ROTARY_ENCODERS 0
#define NUM_ROTARY_ENCODERS_EXTRA 0
#define ROTARY_ENCODER_ARRAY_EXTRA
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[1];
#elif defined(PCBSKY9X)
@@ -574,12 +578,12 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data
#define NUM_ROTARY_ENCODERS 1
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[1];
#define ROTARY_ENCODER_ARRAY_EXTRA
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define NUM_ROTARY_ENCODERS_EXTRA 2
#define NUM_ROTARY_ENCODERS (2+NUM_ROTARY_ENCODERS_EXTRA)
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[2];
#define ROTARY_ENCODER_ARRAY_EXTRA int16_t rotaryEncodersExtra[MAX_PHASES][NUM_ROTARY_ENCODERS_EXTRA];
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define NUM_ROTARY_ENCODERS_EXTRA 0
#define NUM_ROTARY_ENCODERS 2
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[2];
@@ -692,7 +696,7 @@ enum MixSources {
#elif defined(PCBGRUVIN9X)
MIXSRC_REa,
MIXSRC_REb,
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
MIXSRC_REc,
MIXSRC_REd,
#endif
+24 -22
View File
@@ -643,16 +643,16 @@ int16_t getValue(uint8_t i)
else if(i<MIXSRC_TrimAil) return calc1000toRESX((int16_t)8 * getTrimValue(s_perout_flight_phase, i-(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS)));
else if(i<MIXSRC_MAX) return 1024;
#if defined(PCBX9D) || defined(PCBACT)
else if(i<MIXSRC_SA) return (keyState(SW_SA0) ? -1024 : (keyState(SW_SA1) ? 0 : 1024));
else if(i<MIXSRC_SB) return (keyState(SW_SB0) ? -1024 : (keyState(SW_SB1) ? 0 : 1024));
else if(i<MIXSRC_SC) return (keyState(SW_SC0) ? -1024 : (keyState(SW_SC1) ? 0 : 1024));
else if(i<MIXSRC_SD) return (keyState(SW_SD0) ? -1024 : (keyState(SW_SD1) ? 0 : 1024));
else if(i<MIXSRC_SE) return (keyState(SW_SE0) ? -1024 : (keyState(SW_SE1) ? 0 : 1024));
else if(i<MIXSRC_SF) return (keyState(SW_SF0) ? -1024 : 1024);
else if(i<MIXSRC_SG) return (keyState(SW_SG0) ? -1024 : (keyState(SW_SG1) ? 0 : 1024));
else if(i<MIXSRC_SH) return (keyState(SW_SH0) ? -1024 : 1024);
else if(i<MIXSRC_SA) return (switchState(SW_SA0) ? -1024 : (switchState(SW_SA1) ? 0 : 1024));
else if(i<MIXSRC_SB) return (switchState(SW_SB0) ? -1024 : (switchState(SW_SB1) ? 0 : 1024));
else if(i<MIXSRC_SC) return (switchState(SW_SC0) ? -1024 : (switchState(SW_SC1) ? 0 : 1024));
else if(i<MIXSRC_SD) return (switchState(SW_SD0) ? -1024 : (switchState(SW_SD1) ? 0 : 1024));
else if(i<MIXSRC_SE) return (switchState(SW_SE0) ? -1024 : (switchState(SW_SE1) ? 0 : 1024));
else if(i<MIXSRC_SF) return (switchState(SW_SF0) ? -1024 : 1024);
else if(i<MIXSRC_SG) return (switchState(SW_SG0) ? -1024 : (switchState(SW_SG1) ? 0 : 1024));
else if(i<MIXSRC_SH) return (switchState(SW_SH0) ? -1024 : 1024);
#else
else if(i<MIXSRC_3POS) return (keyState(SW_ID0) ? -1024 : (keyState(SW_ID1) ? 0 : 1024));
else if(i<MIXSRC_3POS) return (switchState(SW_ID0) ? -1024 : (switchState(SW_ID1) ? 0 : 1024));
// here the switches are skipped
else if(i<MIXSRC_3POS+3)
#if defined(HELI)
@@ -734,7 +734,7 @@ bool __getSwitch(int8_t swtch)
result = true;
}
else if (cs_idx <= MAX_PSWITCH) {
result = keyState((EnumKeys)(SW_BASE+cs_idx-1));
result = switchState((EnumKeys)(SW_BASE+cs_idx-1));
}
else {
cs_idx -= MAX_PSWITCH+1;
@@ -1022,7 +1022,7 @@ uint8_t getRotaryEncoderFlightPhase(uint8_t idx)
uint8_t phase = s_perout_flight_phase;
for (uint8_t i=0; i<MAX_PHASES; i++) {
if (phase == 0) return 0;
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
int16_t value;
if(idx<(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
value = phaseaddress(phase)->rotaryEncoders[idx];
@@ -1041,7 +1041,7 @@ uint8_t getRotaryEncoderFlightPhase(uint8_t idx)
int16_t getRotaryEncoder(uint8_t idx)
{
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
if(idx >= (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
return g_model.rotaryEncodersExtra[getRotaryEncoderFlightPhase(idx)][idx-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)];
#endif
@@ -1051,7 +1051,7 @@ int16_t getRotaryEncoder(uint8_t idx)
void incRotaryEncoder(uint8_t idx, int8_t inc)
{
g_rotenc[idx] += inc;
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
int16_t *value;
if (idx < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
value = &(phaseaddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]);
@@ -1399,8 +1399,8 @@ void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SO
{
lcd_clear();
#if LCD >= 212
lcd_img(DISPLAY_W-29, 0, asterisk_lbm, 0, 0);
#if LCD_W >= 212
lcd_img(LCD_W-29, 0, asterisk_lbm, 0, 0);
#endif
#if !defined(CPUM64) || defined(EXTSTD)
lcd_img(2, 0, asterisk_lbm, 0, 0);
@@ -1414,7 +1414,7 @@ void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SO
lcd_putsAtt(6*FW, 0, title, DBLSIZE);
lcd_putsAtt(6*FW, 2*FH, STR_WARNING, DBLSIZE);
#endif
lcd_filled_rect(0, 0, DISPLAY_W, 32);
lcd_filled_rect(0, 0, LCD_W, 32);
if (t) lcd_putsLeft(5*FH, t);
if (last) {
lcd_putsLeft(7*FH, last);
@@ -2398,7 +2398,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
if (sDelay[i])
sDelay[i] = 0;
else
sDelay[i] = md->delayUp * 50;
sDelay[i] = md->delayUp * (100/DELAY_STEP);
}
if (sDelay[i] > 0) { // perform delay
sDelay[i] = max(0, sDelay[i] - tick10ms);
@@ -2422,7 +2422,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
if (sDelay[i])
sDelay[i] = 0;
else
sDelay[i] = md->delayDown * 50;
sDelay[i] = md->delayDown * (100/DELAY_STEP);
}
if (sDelay[i] > 0) { // perform delay
sDelay[i] = max(0, sDelay[i] - tick10ms);
@@ -2486,8 +2486,8 @@ void perOut(uint8_t mode, uint8_t tick10ms)
int32_t rate = (int32_t) DEL_MULT * 2048 * 100 * tick10ms;
if (weight) rate /= abs(weight);
act[i] = (diff>0) ? ((md->speedUp>0) ? act[i]+(rate)/((int16_t)50*md->speedUp) : (int32_t)v*DEL_MULT) :
((md->speedDown>0) ? act[i]-(rate)/((int16_t)50*md->speedDown) : (int32_t)v*DEL_MULT) ;
act[i] = (diff>0) ? ((md->speedUp>0) ? act[i]+(rate)/((int16_t)(100/SLOW_STEP)*md->speedUp) : (int32_t)v*DEL_MULT) :
((md->speedDown>0) ? act[i]-(rate)/((int16_t)(100/SLOW_STEP)*md->speedDown) : (int32_t)v*DEL_MULT) ;
}
{
@@ -2610,7 +2610,7 @@ void doMixerCalculations()
ACTIVE_PHASES_TYPE transitionMask = ((ACTIVE_PHASES_TYPE)1 << s_last_phase) + ((ACTIVE_PHASES_TYPE)1 << phase);
if (fadeTime) {
s_fade_flight_phases |= transitionMask;
delta = (MAX_ACT / 50) / fadeTime;
delta = (MAX_ACT / (100/SLOW_STEP)) / fadeTime;
}
else {
s_fade_flight_phases &= ~transitionMask;
@@ -3309,7 +3309,9 @@ void saveTimers()
}
#endif
#if defined(ROTARY_ENCODERS)
#if defined(PCBACT)
volatile rotenc_t g_rotenc[1] = {0};
#elif defined(ROTARY_ENCODERS)
volatile rotenc_t g_rotenc[ROTARY_ENCODERS] = {0};
#endif
+43 -18
View File
@@ -151,6 +151,10 @@
#define IF_GVARS(x)
#endif
#if defined(PCBX9D) || defined(PCBACT) || ROTARY_ENCODERS > 0
#define ROTARY_ENCODER_NAVIGATION
#endif
/*
#define HELI_VARIANT 0x0004
#define VOICE_VARIANT 0x0008
@@ -172,7 +176,7 @@
#include "stock/board_stock.h"
#endif
#if defined(CPUARM) && defined(DEBUG)
#if defined(CPUARM)
#include "debug.h"
#endif
@@ -208,7 +212,7 @@ extern void boardInit();
#include "myeeprom.h"
#if defined(ROTARY_ENCODERS) && NUM_ROTARY_ENCODERS > 0
#if ROTARY_ENCODERS > 0
#define IF_ROTARY_ENCODERS(x) x,
#else
#define IF_ROTARY_ENCODERS(x)
@@ -484,7 +488,12 @@ extern uint8_t channel_order(uint8_t x);
enum EnumKeys {
KEY_MENU,
KEY_EXIT,
#if defined(PCBX9D) || defined(PCBACT)
#if defined(PCBACT)
KEY_CLR,
KEY_PAGE,
KEY_PLUS, /* Fake, used for rotary encoder */
KEY_MINUS, /* Fake, used for rotary encoder */
#elif defined(PCBX9D)
KEY_ENTER,
KEY_PAGE,
KEY_PLUS,
@@ -503,8 +512,11 @@ enum EnumKeys {
TRM_RV_UP,
TRM_RH_DWN,
TRM_RH_UP,
#if defined(ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 0 || defined(ROTARY_ENCODER_NAVIGATION)
BTN_REa,
#endif
#if ROTARY_ENCODERS > 0
BTN_REb,
#endif
@@ -564,11 +576,24 @@ enum EnumKeys {
#define DSW(x) (1+(x)-SW_BASE)
#if defined(PCBX9D) || defined(PCBACT)
#if defined(PCBACT)
#define KEY_ENTER BTN_REa
#define KEY_RIGHT KEY_PLUS
#define KEY_UP KEY_PLUS
#define KEY_LEFT KEY_MINUS
#define KEY_UP KEY_MINUS
#define KEY_DOWN KEY_PLUS
#elif defined(PCBX9D)
#define KEY_RIGHT KEY_PLUS
#define KEY_LEFT KEY_MINUS
#define KEY_UP KEY_PLUS
#define KEY_DOWN KEY_MINUS
#else
#define KEY_ENTER KEY_MENU
#define KEY_PLUS KEY_RIGHT
#define KEY_MINUS KEY_LEFT
#endif
#if defined(PCBX9D) || defined(PCBACT)
/* mapping of 9x switches */
#define SW_THR SW_SA2
#define SW_RUD SW_SB2
@@ -579,10 +604,6 @@ enum EnumKeys {
#define SW_AIL SW_SF2
#define SW_GEA SW_SG2
#define SW_TRN SW_SH2
#else
#define KEY_ENTER KEY_MENU
#define KEY_PLUS KEY_RIGHT
#define KEY_MINUS KEY_LEFT
#endif
class Key
@@ -776,9 +797,9 @@ enum PowerState {
};
#if defined(CPUARM)
uint32_t keyState(EnumKeys enuk);
uint32_t switchState(EnumKeys enuk);
#else
bool keyState(EnumKeys enuk);
bool switchState(EnumKeys enuk);
#if defined(PCBGRUVIN9X)
uint8_t check_soft_power();
#else
@@ -865,12 +886,13 @@ inline bool navigationRotaryEncoder(uint8_t event)
{
return g_eeGeneral.reNavigation == ((event & EVT_KEY_MASK) - BTN_REa + 1);
}
#endif
#if defined(PCBSKY9X)
#define ROTARY_ENCODER_GRANULARITY 4
#else
#define ROTARY_ENCODER_GRANULARITY 1
#endif
#endif
#if defined(GVARS)
#if defined(CPUM64)
@@ -1195,13 +1217,16 @@ inline bool isFunctionActive(uint8_t func)
return activeFunctions & ((MASK_FUNC_TYPE)1 << (func-FUNC_TRAINER));
}
#if defined(ROTARY_ENCODERS)
// Global rotary encoder registers
#if defined(PCBSKY9X)
#if defined(CPUARM)
typedef uint32_t rotenc_t;
#else
typedef uint8_t rotenc_t;
#endif
#if defined(PCBACT)
extern volatile rotenc_t g_rotenc[1];
#elif defined(ROTARY_ENCODERS)
// Global rotary encoder registers
extern volatile rotenc_t g_rotenc[ROTARY_ENCODERS];
#endif
@@ -1336,7 +1361,7 @@ union ReusableBuffer
struct
{
char mainname[42];
char listnames[7][LEN_MODEL_NAME];
char listnames[LCD_LINES-1][LEN_MODEL_NAME];
uint16_t eepromfree;
#if defined(SDCARD)
@@ -1355,7 +1380,7 @@ union ReusableBuffer
#if defined(SDCARD)
struct
{
char lines[7][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line
char lines[LCD_LINES-1][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line
uint32_t available;
uint16_t offset;
uint16_t count;
+2 -2
View File
@@ -312,10 +312,10 @@ void setupPulsesDsm2(uint8_t chns)
break;
}
}
#if defined(PCBX9D)
#if defined(PCBX9D) || defined(PCBACT)
// TODO
#else
if ((dsmDat[0] & BIND_BIT) && (!keyState(SW_TRN))) dsmDat[0] &= ~BIND_BIT; // clear bind bit if trainer not pulled
if ((dsmDat[0] & BIND_BIT) && (!switchState(SW_TRN))) dsmDat[0] &= ~BIND_BIT; // clear bind bit if trainer not pulled
#endif
// TODO find a way to do that, FUNC SWITCH: if ((!(dsmDat[0] & BIND_BIT)) && getSwitch(MAX_DRSWITCH-1, 0, 0)) dsmDat[0] |= RANGECHECK_BIT; // range check function
+2 -2
View File
@@ -392,7 +392,7 @@ FORCEINLINE void setupPulsesDsm2()
break;
}
if (s_bind_allowed) s_bind_allowed--;
if (s_bind_allowed && keyState(SW_TRN))
if (s_bind_allowed && switchState(SW_TRN))
{
s_bind_mode = true;
*ptr |= BIND_BIT;
@@ -521,7 +521,7 @@ void setupPulsesDsm2()
}
if (s_bind_allowed) s_bind_allowed--;
if (s_bind_allowed && keyState(SW_TRN))
if (s_bind_allowed && switchState(SW_TRN))
{
s_bind_mode = true;
dsmDat[0] |= BIND_BIT;
+62 -25
View File
@@ -75,26 +75,63 @@ extern const char* eeprom_buffer_data;
uint8_t eeprom[EESIZE];
sem_t *eeprom_write_sem;
#if defined(CPUARM)
#define SWITCH_CASE(swtch, pin, bit) \
#define SWITCH_CASE(swtch, pin, mask) \
case -DSW(swtch): \
pin &= ~(1<<bit); \
pin &= ~mask; \
break; \
case DSW(swtch): \
pin |= (1<<bit); \
pin |= mask; \
break;
#define KEY_CASE(key, pin, mask) \
case -1-key: \
pin |= mask; \
break; \
case 1+key: \
pin &= ~mask; \
break;
#else
#define SWITCH_CASE(swtch, pin, bit) \
#define SWITCH_CASE(swtch, pin, mask) \
case DSW(swtch): \
pin &= ~(1<<bit); \
pin &= ~mask; \
break; \
case -DSW(swtch): \
pin |= (1<<bit); \
pin |= mask; \
break;
#define KEY_CASE(key, pin, mask) \
case 1+key: \
pin |= mask; \
break; \
case -1-key: \
pin &= ~mask; \
break;
#endif
void simuSetKey(int8_t key)
{
switch (key) {
KEY_CASE(KEY_MENU, GPIO_BUTTON_MENU, PIN_BUTTON_MENU)
KEY_CASE(KEY_EXIT, GPIO_BUTTON_EXIT, PIN_BUTTON_EXIT)
#if defined(PCBACT)
KEY_CASE(KEY_CLR, GPIO_BUTTON_CLR, PIN_BUTTON_CLR)
KEY_CASE(KEY_PAGE, GPIO_BUTTON_PAGE, PIN_BUTTON_PAGE)
KEY_CASE(BTN_REa, GPIO_BUTTON_ENTER, PIN_BUTTON_ENTER)
#elif defined(PCBX9D)
KEY_CASE(KEY_ENTER, GPIO_BUTTON_ENTER, PIN_BUTTON_ENTER)
KEY_CASE(KEY_PAGE, GPIO_BUTTON_PAGE, PIN_BUTTON_PAGE)
KEY_CASE(KEY_MINUS, GPIO_BUTTON_MINUS, PIN_BUTTON_MINUS)
KEY_CASE(KEY_PLUS, GPIO_BUTTON_PLUS, PIN_BUTTON_PLUS)
#else
KEY_CASE(KEY_RIGHT, GPIO_BUTTON_RIGHT, PIN_BUTTON_RIGHT)
KEY_CASE(KEY_LEFT, GPIO_BUTTON_LEFT, PIN_BUTTON_LEFT)
KEY_CASE(KEY_UP, GPIO_BUTTON_UP, PIN_BUTTON_UP)
KEY_CASE(KEY_DOWN, GPIO_BUTTON_DOWN, PIN_BUTTON_DOWN)
#endif
}
}
void setSwitch(int8_t swtch)
void simuSetSwitch(int8_t swtch)
{
switch (swtch) {
#if defined(PCBACT)
@@ -196,16 +233,16 @@ void setSwitch(int8_t swtch)
PIOC->PIO_PDSR |= 0x00004000;
break;
SWITCH_CASE(SW_THR, PIOC->PIO_PDSR, 20)
SWITCH_CASE(SW_RUD, PIOA->PIO_PDSR, 15)
SWITCH_CASE(SW_ELE, PIOC->PIO_PDSR, 31)
SWITCH_CASE(SW_AIL, PIOA->PIO_PDSR, 2)
SWITCH_CASE(SW_GEA, PIOC->PIO_PDSR, 16)
SWITCH_CASE(SW_TRN, PIOC->PIO_PDSR, 8)
SWITCH_CASE(SW_THR, PIOC->PIO_PDSR, 1<<20)
SWITCH_CASE(SW_RUD, PIOA->PIO_PDSR, 1<<15)
SWITCH_CASE(SW_ELE, PIOC->PIO_PDSR, 1<<31)
SWITCH_CASE(SW_AIL, PIOA->PIO_PDSR, 1<<2)
SWITCH_CASE(SW_GEA, PIOC->PIO_PDSR, 1<<16)
SWITCH_CASE(SW_TRN, PIOC->PIO_PDSR, 1<<8)
#elif defined(PCBGRUVIN9X)
SWITCH_CASE(SW_THR, ping, INP_G_ThrCt)
SWITCH_CASE(SW_RUD, ping, INP_G_RuddDR)
SWITCH_CASE(SW_ELE, pinc, INP_C_ElevDR)
SWITCH_CASE(SW_THR, ping, 1<<INP_G_ThrCt)
SWITCH_CASE(SW_RUD, ping, 1<<INP_G_RuddDR)
SWITCH_CASE(SW_ELE, pinc, 1<<INP_C_ElevDR)
case DSW(SW_ID0):
ping |= (1<<INP_G_ID1);
@@ -220,13 +257,13 @@ void setSwitch(int8_t swtch)
pinb |= (1<<INP_B_ID2);
break;
SWITCH_CASE(SW_AIL, pinc, INP_C_AileDR)
SWITCH_CASE(SW_GEA, ping, INP_G_Gear)
SWITCH_CASE(SW_TRN, pinb, INP_B_Trainer)
SWITCH_CASE(SW_AIL, pinc, 1<<INP_C_AileDR)
SWITCH_CASE(SW_GEA, ping, 1<<INP_G_Gear)
SWITCH_CASE(SW_TRN, pinb, 1<<INP_B_Trainer)
#else // STOCK
#if defined(JETI) || defined(FRSKY) || defined(NMEA) || defined(ARDUPILOT)
SWITCH_CASE(SW_THR, pinc, INP_C_ThrCt)
SWITCH_CASE(SW_AIL, pinc, INP_C_AileDR)
SWITCH_CASE(SW_THR, pinc, 1<<INP_C_ThrCt)
SWITCH_CASE(SW_AIL, pinc, 1<<INP_C_AileDR)
#else
SWITCH_CASE(SW_THR, pine, INP_E_ThrCt)
SWITCH_CASE(SW_AIL, pine, INP_E_AileDR)
@@ -244,10 +281,10 @@ void setSwitch(int8_t swtch)
pine |= (1<<INP_E_ID2);
break;
SWITCH_CASE(SW_RUD, ping, INP_G_RuddDR)
SWITCH_CASE(SW_ELE, pine, INP_E_ElevDR)
SWITCH_CASE(SW_GEA, pine, INP_E_Gear)
SWITCH_CASE(SW_TRN, pine, INP_E_Trainer)
SWITCH_CASE(SW_RUD, ping, 1<<INP_G_RuddDR)
SWITCH_CASE(SW_ELE, pine, 1<<INP_E_ElevDR)
SWITCH_CASE(SW_GEA, pine, 1<<INP_E_Gear)
SWITCH_CASE(SW_TRN, pine, 1<<INP_E_Trainer)
#endif
default:
+2 -1
View File
@@ -312,7 +312,8 @@ extern uint8_t main_thread_running;
#define SIMU_SLEEP(x) do { if (!main_thread_running) return; sleep(x/*ms*/); } while (0)
extern void setSwitch(int8_t swtch);
void simuSetKey(int8_t key);
void simuSetSwitch(int8_t swtch);
void StartMainThread(bool tests=true);
void StartEepromThread(const char *filename="eeprom.bin");
+58 -123
View File
@@ -42,77 +42,14 @@
#include <time.h>
#include <ctype.h>
#define W DISPLAY_W
#define H DISPLAY_H
#define W2 W*2
#define H2 H*2
#define W2 LCD_W*2
#define H2 LCD_H*2
int g_snapshot_idx = 0;
uint64_t toto = 0;
#if defined(PCBACT)
#define ERSKY9X_RETURN_PIO GPIOC->IDR
#define ERSKY9X_RETURN_MASK 0x00000020
#define ERSKY9X_EXIT_PIO GPIOC->IDR
#define ERSKY9X_EXIT_MASK 0x01000000
#define ERSKY9X_UP_PIO GPIOC->IDR
#define ERSKY9X_UP_MASK 0x00
#define ERSKY9X_DOWN_PIO GPIOC->IDR
#define ERSKY9X_DOWN_MASK 0x00
#define ERSKY9X_RIGHT_PIO GPIOC->IDR
#define ERSKY9X_RIGHT_MASK 0x00000010
#define ERSKY9X_LEFT_PIO GPIOC->IDR
#define ERSKY9X_LEFT_MASK 0x00000008
#define KEY_MENU_PIO GPIOC->IDR
#define KEY_MENU_MASK 0x00000002
#define KEY_PAGE_PIO GPIOC->IDR
#define KEY_PAGE_MASK 0x00000040
#elif defined(PCBX9D)
#define ERSKY9X_RETURN_PIO GPIOE->IDR
#define ERSKY9X_RETURN_MASK PIN_BUTTON_ENTER
#define ERSKY9X_EXIT_PIO GPIOD->IDR
#define ERSKY9X_EXIT_MASK PIN_BUTTON_EXIT
#define ERSKY9X_UP_PIO GPIOC->IDR
#define ERSKY9X_UP_MASK 0x00
#define ERSKY9X_DOWN_PIO GPIOC->IDR
#define ERSKY9X_DOWN_MASK 0x00
#define ERSKY9X_RIGHT_PIO GPIOE->IDR
#define ERSKY9X_RIGHT_MASK PIN_BUTTON_PLUS
#define ERSKY9X_LEFT_PIO GPIOE->IDR
#define ERSKY9X_LEFT_MASK PIN_BUTTON_MINUS
#define KEY_MENU_PIO GPIOD->IDR
#define KEY_MENU_MASK PIN_BUTTON_MENU
#define KEY_PAGE_PIO GPIOD->IDR
#define KEY_PAGE_MASK PIN_BUTTON_PAGE
#elif defined(PCBSKY9X) && defined(REVA)
#define ERSKY9X_RETURN_PIO PIOB->PIO_PDSR
#define ERSKY9X_RETURN_MASK (0x40)
#define ERSKY9X_EXIT_PIO PIOA->PIO_PDSR
#define ERSKY9X_EXIT_MASK (0x80000000)
#define ERSKY9X_UP_PIO PIOC
#define ERSKY9X_UP_MASK (0x08 >> 1)
#define ERSKY9X_RIGHT_PIO PIOC->PIO_PDSR
#define ERSKY9X_RIGHT_MASK (0x20 >> 1)
#define ERSKY9X_DOWN_PIO PIOC->PIO_PDSR
#define ERSKY9X_DOWN_MASK (0x10 >> 1)
#define ERSKY9X_LEFT_PIO PIOC->PIO_PDSR
#define ERSKY9X_LEFT_MASK (0x40 >> 1)
#elif defined(PCBSKY9X)
#define ERSKY9X_RETURN_PIO PIOB->PIO_PDSR
#define ERSKY9X_RETURN_MASK (0x20)
#define ERSKY9X_EXIT_MASK (0x01000000)
#define ERSKY9X_EXIT_PIO PIOC->PIO_PDSR
#define ERSKY9X_UP_PIO PIOC->PIO_PDSR
#define ERSKY9X_UP_MASK (0x04 >> 1)
#define ERSKY9X_RIGHT_PIO PIOC->PIO_PDSR
#define ERSKY9X_RIGHT_MASK (0x20 >> 1)
#define ERSKY9X_DOWN_PIO PIOC->PIO_PDSR
#define ERSKY9X_DOWN_MASK (0x40 >> 1)
#define ERSKY9X_LEFT_PIO PIOC->PIO_PDSR
#define ERSKY9X_LEFT_MASK (0x10 >> 1)
#define ERSKY9X_MENU_MASK (0x04 >> 1)
#else
// TODO to remove
#if !defined(CPUARM)
// TODO remove!
uint64_t toto = 0;
#define ERSKY9X_RETURN_PIO toto
#define ERSKY9X_RETURN_MASK toto
#define ERSKY9X_EXIT_MASK toto
@@ -170,7 +107,7 @@ Open9xSim::Open9xSim(FXApp* a)
{
firstTime=true;
for(int i=0; i<(W*H/8); i++) displayBuf[i]=0;//rand();
for(int i=0; i<(LCD_W*LCD_H/8); i++) displayBuf[i]=0;//rand();
bmp = new FXPPMImage(getApp(),NULL,IMAGE_OWNED|IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP, W2, H2);
FXHorizontalFrame *hf00=new FXHorizontalFrame(this,LAYOUT_CENTER_X);
@@ -314,19 +251,27 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
}
if(hasFocus()) {
static uint64_t keys1[]={
// TODO change everything here!
KEY_Return, INP_B_KEY_MEN, INP_L_KEY_MEN, (uint64_t)&ERSKY9X_RETURN_PIO, ERSKY9X_RETURN_MASK,
KEY_BackSpace, INP_B_KEY_EXT, INP_L_KEY_EXT, (uint64_t)&ERSKY9X_EXIT_PIO, ERSKY9X_EXIT_MASK,
KEY_KP_0, INP_B_KEY_EXT, INP_L_KEY_EXT, (uint64_t)&ERSKY9X_EXIT_PIO, ERSKY9X_EXIT_MASK,
KEY_Right, INP_B_KEY_RGT, INP_L_KEY_RGT, (uint64_t)&ERSKY9X_RIGHT_PIO, ERSKY9X_RIGHT_MASK,
KEY_Left, INP_B_KEY_LFT, INP_L_KEY_LFT, (uint64_t)&ERSKY9X_LEFT_PIO, ERSKY9X_LEFT_MASK,
#if defined(PCBX9D)
KEY_Page_Up, INP_B_KEY_MEN, INP_L_KEY_MEN, (uint64_t)&KEY_MENU_PIO, KEY_MENU_MASK,
KEY_Page_Down, INP_B_KEY_EXT, INP_L_KEY_EXT, (uint64_t)&KEY_PAGE_PIO, KEY_PAGE_MASK,
static int keys1[]={
#if defined(PCBACT)
KEY_Page_Up, KEY_MENU,
KEY_BackSpace, KEY_EXIT,
KEY_Page_Down, KEY_PAGE,
KEY_Clear, KEY_CLR,
KEY_Return, BTN_REa,
#elif defined(PCBX9D)
KEY_Page_Up, KEY_MENU,
KEY_Page_Down, KEY_PAGE,
KEY_Return, KEY_ENTER,
KEY_BackSpace, KEY_EXIT,
KEY_Right, KEY_PLUS,
KEY_Left, KEY_MINUS,
#else
KEY_Up, INP_B_KEY_UP, INP_L_KEY_UP, (uint64_t)&ERSKY9X_UP_PIO, ERSKY9X_UP_MASK,
KEY_Down, INP_B_KEY_DWN, INP_L_KEY_DWN, (uint64_t)&ERSKY9X_DOWN_PIO, ERSKY9X_DOWN_MASK,
KEY_Return, KEY_MENU,
KEY_BackSpace, KEY_EXIT,
KEY_Right, KEY_RIGHT,
KEY_Left, KEY_LEFT,
KEY_Up, KEY_UP,
KEY_Down, KEY_DOWN,
#endif
};
@@ -336,41 +281,31 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
#endif
#if defined(CPUARM)
ERSKY9X_UP_PIO |= ERSKY9X_UP_MASK;
ERSKY9X_DOWN_PIO |= ERSKY9X_DOWN_MASK;
ERSKY9X_LEFT_PIO |= ERSKY9X_LEFT_MASK;
ERSKY9X_RIGHT_PIO |= ERSKY9X_RIGHT_MASK;
ERSKY9X_EXIT_PIO |= ERSKY9X_EXIT_MASK;
ERSKY9X_RETURN_PIO |= ERSKY9X_RETURN_MASK;
#if defined(PCBX9D)
KEY_MENU_PIO |= KEY_MENU_MASK;
KEY_PAGE_PIO |= KEY_PAGE_MASK;
#endif
temperature = 31;
maxTemperature = 42;
#elif defined(PCBGRUVIN9X)
uint8_t pin = (pinl & ~0x3f);
#else
uint8_t pin = (pinb & ~0x7e);
#endif
for(unsigned i=0; i<DIM(keys1);i+=5) {
if (getApp()->getKeyState(keys1[i])) {
#if defined(CPUARM)
*((uint32_t*)keys1[i+3]) &= ~(keys1[i+4]);
#elif defined(PCBGRUVIN9X)
pin |= (1<<keys1[i+2]);
#else
pin |= (1<<keys1[i+1]);
#endif
}
for (unsigned int i=0; i<DIM(keys1); i+=2) {
if (getApp()->getKeyState(keys1[i]))
simuSetKey(1+keys1[i+1]);
else
simuSetKey(-1-keys1[i+1]);
}
#if defined(CPUARM)
#elif defined(PCBGRUVIN9X)
pinl = pin;
#else
pinb = pin;
#if defined(PCBACT)
static bool rotencState = false;
if (rotencState) {
if (!getApp()->getKeyState(KEY_Right) && !getApp()->getKeyState(KEY_Left))
rotencState = false;
}
else if (getApp()->getKeyState(KEY_Right)) {
g_rotenc[0] -= 1;
rotencState = true;
}
else if (getApp()->getKeyState(KEY_Left)) {
g_rotenc[0] += 1;
rotencState = true;
}
#endif
#ifdef __APPLE__
@@ -384,9 +319,9 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
#if defined(PCBX9D)
GPIOE->IDR |= PIN_TRIM_LH_L | PIN_TRIM_LH_R | PIN_TRIM_LV_DN | PIN_TRIM_LV_UP;
GPIOC->IDR |= PIN_TRIM_RV_DN | PIN_TRIM_RV_UP | PIN_TRIM_RH_L | PIN_TRIM_RH_R;
GPIOE->IDR |= 0xFFFFFFFF;
GPIOB->IDR |= 0xFFFFFFFF;
GPIOC->IDR |= 0xFFFFFFFF;
// GPIOE->IDR |= 0xFFFFFFFF;
// GPIOB->IDR |= 0xFFFFFFFF;
// GPIOC->IDR |= 0xFFFFFFFF;
#elif defined(PCBSKY9X)
PIOA->PIO_PDSR |= (0x00800000 | 0x01000000 | 0x00000002 | 0x00000001);
PIOB->PIO_PDSR |= (0x00000050);
@@ -442,7 +377,7 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
if (getApp()->getKeyState(KEY_##key)) { \
if (!state##key) { \
state##swtch = (state##swtch+1) % states; \
setSwitch(DSW(SW_##swtch+state##swtch)); \
simuSetSwitch(DSW(SW_##swtch+state##swtch)); \
state##key = true; \
} \
} \
@@ -457,9 +392,9 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
if (!state##key) { \
state##swtch = (state##swtch+1) % states; \
if (states > 2) \
setSwitch(DSW(SW_##swtch+state##swtch)); \
simuSetSwitch(DSW(SW_##swtch+state##swtch)); \
else \
setSwitch(state##swtch ? DSW(SW_##swtch) : -DSW(SW_##swtch)); \
simuSetSwitch(state##swtch ? DSW(SW_##swtch) : -DSW(SW_##swtch)); \
state##key = true; \
} \
} \
@@ -468,7 +403,7 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
}
#endif
#if defined(PCBX9D)
#if defined(PCBX9D) || defined(PCBACT)
SWITCH_KEY(A, SA0, 3);
SWITCH_KEY(B, SB0, 3);
SWITCH_KEY(C, SC0, 3);
@@ -508,12 +443,12 @@ void Open9xSim::refreshDiplay()
#if !defined(PCBX9D)
FXColor onColor = FXRGB(0,0,0);
#endif
for (int x=0;x<W;x++) {
for (int y=0; y<H; y++) {
for (int x=0;x<LCD_W;x++) {
for (int y=0; y<LCD_H; y++) {
#if defined(PCBX9D)
#define PALETTE_IDX(p, x, mask) ((((p)[(x)] & (mask)) ? 0x1 : 0) + (((p)[DISPLAY_PLAN_SIZE+(x)] & (mask)) ? 0x2 : 0) + (((p)[2*DISPLAY_PLAN_SIZE+(x)] & (mask)) ? 0x4 : 0) + (((p)[3*DISPLAY_PLAN_SIZE+(x)] & (mask)) ? 0x8 : 0))
uint8_t mask = (1 << (y%8));
uint32_t z = PALETTE_IDX(lcd_buf, (y/8)*W+x, mask);
uint32_t z = PALETTE_IDX(lcd_buf, (y/8)*LCD_W+x, mask);
if (z) {
FXColor color;
if (IS_BACKLIGHT_ON())
@@ -526,7 +461,7 @@ void Open9xSim::refreshDiplay()
bmp->setPixel(2*x+1, 2*y+1, color);
}
#else
if (lcd_buf[x+(y/8)*W] & (1<<(y%8))) {
if (lcd_buf[x+(y/8)*LCD_W] & (1<<(y%8))) {
bmp->setPixel(2*x, 2*y, onColor);
bmp->setPixel(2*x+1, 2*y, onColor);
bmp->setPixel(2*x, 2*y+1, onColor);
@@ -572,8 +507,8 @@ int main(int argc,char **argv)
// so that persistent settings are now available.
application.init(argc,argv);
#if !defined(PCBX9D)
setSwitch(DSW(SW_ID0));
#if !defined(PCBX9D) && !defined(PCBACT)
simuSetSwitch(DSW(SW_ID0));
#endif
// This creates the main window. We pass in the title to be displayed
+6
View File
@@ -36,8 +36,14 @@
void pwrInit();
void eepromInit();
#if defined(DEBUG) && !defined(SIMU)
void DEBUG_UART_Configure( uint32_t baudrate, uint32_t masterClock);
void DEBUG_UART_Stop();
#else
#define DEBUG_UART_Stop()
#define DEBUG_UART_Configure(...)
#endif
uint32_t Master_frequency ;
volatile uint32_t Tenms ;
+28
View File
@@ -49,6 +49,34 @@ extern void init_SDcard();
extern void sdInit();
}
#if defined(REVA)
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
#define GPIO_BUTTON_EXIT PIOA->PIO_PDSR
#define GPIO_BUTTON_UP PIOC->PIO_PDSR
#define GPIO_BUTTON_DOWN PIOC->PIO_PDSR
#define GPIO_BUTTON_RIGHT PIOC->PIO_PDSR
#define GPIO_BUTTON_LEFT PIOC->PIO_PDSR
#define PIN_BUTTON_MENU 0x00000040
#define PIN_BUTTON_EXIT 0x80000000
#define PIN_BUTTON_UP 0x00000004
#define PIN_BUTTON_DOWN 0x00000008
#define PIN_BUTTON_RIGHT 0x00000010
#define PIN_BUTTON_LEFT 0x00000020
#else
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
#define GPIO_BUTTON_EXIT PIOC->PIO_PDSR
#define GPIO_BUTTON_UP PIOC->PIO_PDSR
#define GPIO_BUTTON_DOWN PIOC->PIO_PDSR
#define GPIO_BUTTON_RIGHT PIOC->PIO_PDSR
#define GPIO_BUTTON_LEFT PIOC->PIO_PDSR
#define PIN_BUTTON_MENU 0x00000020
#define PIN_BUTTON_EXIT 0x01000000
#define PIN_BUTTON_UP 0x00000002
#define PIN_BUTTON_DOWN 0x00000020
#define PIN_BUTTON_RIGHT 0x00000010
#define PIN_BUTTON_LEFT 0x00000008
#endif
#define sdPoll10ms()
void usbMassStorage();
+29 -24
View File
@@ -47,36 +47,41 @@
uint32_t readKeys()
{
register uint32_t x;
register uint32_t y;
register uint32_t result = 0;
x = lcdLock ? lcdInputs : PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
x <<= 1;
#if defined(REVA)
y = (x & 0x00000060);
if (x & 0x00000008)
y |= 0x10;
if (x & 0x00000010)
y |= 0x08;
if (PIOA->PIO_PDSR & 0x80000000)
y |= 0x04; // EXIT
if (PIOB->PIO_PDSR & 0x000000040)
y |= 0x02; // MENU
if (x & PIN_BUTTON_RIGHT)
result |= 0x02 << KEY_RIGHT;
if (x & PIN_BUTTON_LEFT)
result |= 0x02 << KEY_LEFT;
if (x & PIN_BUTTON_UP)
result |= 0x02 << KEY_UP;
if (x & PIN_BUTTON_DOWN)
result |= 0x02 << KEY_DOWN;
if (GPIO_BUTTON_EXIT & PIN_BUTTON_EXIT)
result |= 0x02 << KEY_EXIT;
if (GPIO_BUTTON_MENU & 0x000000040)
result |= 0x02 << KEY_MENU;
#else
y = (x & 0x00000020); // RIGHT
if (x & 0x00000004)
y |= 0x02 << KEY_UP; // UP
if (x & 0x00000010)
y |= 0x02 << KEY_LEFT; // LEFT
if (x & 0x00000040)
y |= 0x02 << KEY_DOWN; // DOWN
if (x & 0x02000000)
y |= 0x02 << KEY_EXIT; // EXIT
if (PIOB->PIO_PDSR & 0x000000020)
y |= 0x02 << KEY_MENU; // MENU
if (x & PIN_BUTTON_RIGHT)
result |= 0x02 << KEY_RIGHT;
if (x & PIN_BUTTON_UP)
result |= 0x02 << KEY_UP;
if (x & PIN_BUTTON_LEFT)
result |= 0x02 << KEY_LEFT;
if (x & PIN_BUTTON_DOWN)
result |= 0x02 << KEY_DOWN;
if (x & PIN_BUTTON_EXIT)
result |= 0x02 << KEY_EXIT;
if (GPIO_BUTTON_MENU & PIN_BUTTON_MENU)
result |= 0x02 << KEY_MENU;
#endif
return y ;
// printf("readKeys(): %x => %x\n", x, result); fflush(stdout);
return result;
}
uint32_t readTrims()
@@ -180,7 +185,7 @@ void readKeysAndTrims()
}
}
extern uint32_t keyState(EnumKeys enuk)
uint32_t switchState(EnumKeys enuk)
{
register uint32_t a;
register uint32_t c;
+1 -1
View File
@@ -253,7 +253,7 @@ void lcdRefresh()
#else
x = *p;
#endif
for (z = 0; z < DISPLAY_W; z += 1) {
for (z = 0; z < LCD_W; z += 1) {
// The following 7 lines replaces by a lookup table
// x = __RBIT( *p++ ) ;
+1 -1
View File
@@ -78,7 +78,7 @@ uint8_t keyDown()
return (~PINB) & 0x7E;
}
bool keyState(EnumKeys enuk)
bool switchState(EnumKeys enuk)
{
uint8_t result = 0 ;
+13
View File
@@ -35,6 +35,19 @@
#ifndef board_stock_h
#define board_stock_h
#define GPIO_BUTTON_MENU pinb
#define GPIO_BUTTON_EXIT pinb
#define GPIO_BUTTON_RIGHT pinb
#define GPIO_BUTTON_LEFT pinb
#define GPIO_BUTTON_UP pinb
#define GPIO_BUTTON_DOWN pinb
#define PIN_BUTTON_MENU (1<<INP_B_KEY_MEN)
#define PIN_BUTTON_EXIT (1<<INP_B_KEY_EXT)
#define PIN_BUTTON_UP (1<<INP_B_KEY_UP)
#define PIN_BUTTON_DOWN (1<<INP_B_KEY_DWN)
#define PIN_BUTTON_RIGHT (1<<INP_B_KEY_RGT)
#define PIN_BUTTON_LEFT (1<<INP_B_KEY_LFT)
#define TIMER_16KHZ_VECT TIMER0_OVF_vect
#define COUNTER_16KHZ TCNT0
+1 -1
View File
@@ -116,7 +116,7 @@ void lcdRefresh()
#endif
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);
for (xcoord_t x=DISPLAY_W; x>0; --x) {
for (xcoord_t x=LCD_W; x>0; --x) {
PORTA_LCD_DAT = *p++;
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
+2 -2
View File
@@ -286,7 +286,7 @@ const pm_char STR_SYNCMENU[] PROGMEM = TR_SYNCMENU;
const pm_char STR_INVERT_THR[] PROGMEM = TR_INVERT_THR;
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
const pm_char STR_BACK[] PROGMEM = TR_BACK;
#endif
@@ -409,7 +409,7 @@ const pm_uchar font_10x14[] PROGMEM = {
#endif
};
#if defined(PCBX9D)
#if defined(CPUARM)
const pm_uchar font_3x5[] PROGMEM = {
#include "font_tiny.lbm"
};
+3 -3
View File
@@ -64,7 +64,7 @@
#define PSIZE(x) ( sizeof(x) - 1 )
#define EOFS(x) ( OFS_##x + sizeof(TR_##x) )
#if LCD >= 212
#if LCD_W >= 212
#define TR(x,y) y
#else
#define TR(x,y) x
@@ -378,7 +378,7 @@ extern const pm_char STR_RXNUM[];
extern const pm_char STR_SYNCMENU[];
extern const pm_char STR_INVERT_THR[];
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODER_NAVIGATION)
extern const pm_char STR_BACK[];
#define LEN_BACK PSIZE(TR_BACK)
#endif
@@ -430,7 +430,7 @@ extern const pm_char STR_MODELS_EXT[];
extern const pm_uchar font_5x7[];
extern const pm_uchar font_10x14[];
#if defined(PCBX9D)
#if defined(CPUARM)
extern const pm_uchar font_3x5[];
extern const pm_uchar font_4x6[];
extern const pm_uchar font_8x10[];
+5 -5
View File
@@ -37,11 +37,11 @@
#define LEN_RETA123 "\001"
#if defined(PCBGRUVIN9X)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define TR_RETA123 "SVPK123abcd"
#else //EXTRA_ROTARY_ENCODERS
#else
#define TR_RETA123 "SVPK123ab"
#endif //EXTRA_ROTARY_ENCODERS
#endif
#else
#define TR_RETA123 "SVPK123"
#endif
@@ -204,9 +204,9 @@
#define LEN_VSRCRAW "\004"
#if defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa "
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd "
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
#else
#define TR_ROTARY_ENCODERS_VSRCRAW
+5 -5
View File
@@ -37,11 +37,11 @@
#define LEN_RETA123 "\001"
#if defined(PCBGRUVIN9X)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define TR_RETA123 "SHGQ123abcd"
#else //EXTRA_ROTARY_ENCODERS
#else
#define TR_RETA123 "SHGQ123ab"
#endif //EXTRA_ROTARY_ENCODERS
#endif
#else
#define TR_RETA123 "SHGQ123"
#endif
@@ -205,9 +205,9 @@
#define LEN_VSRCRAW "\004"
#if defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "DGa\0"
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define TR_ROTARY_ENCODERS_VSRCRAW "DGa ""DGb ""DGc ""DGd "
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define TR_ROTARY_ENCODERS_VSRCRAW "DGa ""DGb "
#else
#define TR_ROTARY_ENCODERS_VSRCRAW
+5 -5
View File
@@ -37,11 +37,11 @@
#define LEN_RETA123 "\001"
#if defined(PCBGRUVIN9X)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define TR_RETA123 "RETA123abcd"
#else //EXTRA_ROTARY_ENCODERS
#else
#define TR_RETA123 "RETA123ab"
#endif //EXTRA_ROTARY_ENCODERS
#endif
#elif defined(PCBX9D)
#define TR_RETA123 "RETA12LR"
#else
@@ -218,9 +218,9 @@
#define TR_ROTARY_ENCODERS_VSRCRAW
#elif defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa "
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd "
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
#else
#define TR_ROTARY_ENCODERS_VSRCRAW
+5 -5
View File
@@ -37,11 +37,11 @@
#define LEN_RETA123 "\001"
#if defined(PCBGRUVIN9X)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define TR_RETA123 "RETA123abcd"
#else //EXTRA_ROTARY_ENCODERS
#else
#define TR_RETA123 "RETA123ab"
#endif //EXTRA_ROTARY_ENCODERS
#endif
#else
#define TR_RETA123 "RETA123"
#endif
@@ -197,9 +197,9 @@
#define LEN_VSRCRAW "\004"
#if defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa "
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd "
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
#else
#define TR_ROTARY_ENCODERS_VSRCRAW
+5 -5
View File
@@ -37,11 +37,11 @@
#define LEN_RETA123 "\001"
#if defined(PCBGRUVIN9X)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define TR_RETA123 "DPGA123abcd"
#else //EXTRA_ROTARY_ENCODERS
#else
#define TR_RETA123 "DPGA123ab"
#endif //EXTRA_ROTARY_ENCODERS
#endif
#else
#define TR_RETA123 "DPGA123"
#endif
@@ -205,9 +205,9 @@
#define LEN_VSRCRAW "\004"
#if defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa\0"
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa\0""REb\0""REc\0""REd\0"
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa\0""REb\0"
#else
#define TR_ROTARY_ENCODERS_VSRCRAW
+5 -5
View File
@@ -36,11 +36,11 @@
#define LEN_RETA123 "\001"
#if defined(PCBGRUVIN9X)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define TR_RETA123 "RETA123abcd"
#else //EXTRA_ROTARY_ENCODERS
#else
#define TR_RETA123 "RETA123ab"
#endif //EXTRA_ROTARY_ENCODERS
#endif
#else
#define TR_RETA123 "RETA123"
#endif
@@ -203,9 +203,9 @@
#define LEN_VSRCRAW "\004"
#if defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa "
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd "
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
#else
#define TR_ROTARY_ENCODERS_VSRCRAW
+5 -5
View File
@@ -37,11 +37,11 @@
#define LEN_RETA123 "\001"
#if defined(PCBGRUVIN9X)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define TR_RETA123 "LPMA123abcd"
#else //EXTRA_ROTARY_ENCODERS
#else
#define TR_RETA123 "LPMA123ab"
#endif //EXTRA_ROTARY_ENCODERS
#endif
#else
#define TR_RETA123 "LPMA123"
#endif
@@ -205,9 +205,9 @@
#define LEN_VSRCRAW "\004"
#if defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa "
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd "
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
#else
#define TR_ROTARY_ENCODERS_VSRCRAW
+5 -5
View File
@@ -37,11 +37,11 @@
#define LEN_RETA123 "\001"
#if defined(PCBGRUVIN9X)
#if defined(EXTRA_ROTARY_ENCODERS)
#if ROTARY_ENCODERS > 2
#define TR_RETA123 "RHGS123abcd"
#else //EXTRA_ROTARY_ENCODERS
#else
#define TR_RETA123 "RHGS123ab"
#endif //EXTRA_ROTARY_ENCODERS
#endif
#else
#define TR_RETA123 "RHGS123"
#endif
@@ -208,9 +208,9 @@
#define LEN_VSRCRAW "\004"
#if defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa "
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd "
#elif defined(PCBGRUVIN9X) && !defined(EXTRA_ROTARY_ENCODERS)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
#else
#define TR_ROTARY_ENCODERS_VSRCRAW
-61
View File
@@ -1,61 +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.
*
*/
#ifndef audio_driver_h
#define audio_driver_h
#define NUM_VOL_LEVELS 24
void startSound( void ) ;
void setFrequency( uint32_t frequency );
uint32_t getFrequency();
void start_timer1( void );
void initDac( void ) ;
void end_sound( void ) ;
extern uint16_t *nextAudioData;
extern uint16_t nextAudioSize;
inline void toneStart()
{
}
inline void toneStop()
{
}
extern void init_twi( void ) ;
extern void setVolume( register uint8_t volume ) ;
#endif
+23 -1
View File
@@ -48,7 +48,6 @@
#include "hal.h"
#include "aspi.h"
#include "i2c_ee.h"
#include "audio_driver.h"
#define PERI1_FREQUENCY 30000000
#define PERI2_FREQUENCY 60000000
@@ -139,4 +138,27 @@ void uartSendChar(uint8_t c);
void delaysInit(void);
void delay_01us(uint16_t nb);
#define NUM_VOL_LEVELS 24
void startSound( void ) ;
void setFrequency( uint32_t frequency );
uint32_t getFrequency();
void start_timer1( void );
void initDac( void ) ;
void end_sound( void ) ;
extern uint16_t *nextAudioData;
extern uint16_t nextAudioSize;
inline void toneStart()
{
}
inline void toneStop()
{
}
extern void init_twi( void ) ;
extern void setVolume( register uint8_t volume ) ;
#endif
+1 -1
View File
@@ -48,7 +48,7 @@ void delaysInit(void)
void delay_01us(uint16_t nb)
{
TIM13->EGR = 1;
TIM13->EGR = 1;
TIM13->CNT = 0;
TIM13->CR1 = 0x03;
while(TIM13->CNT < nb);
+6
View File
@@ -8,6 +8,12 @@
#define RCC_AHB1Periph_GPIOBUTTON (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE)
// Keys
#define GPIO_BUTTON_ENTER GPIOE->IDR
#define GPIO_BUTTON_PLUS GPIOE->IDR
#define GPIO_BUTTON_MINUS GPIOE->IDR
#define GPIO_BUTTON_MENU GPIOD->IDR
#define GPIO_BUTTON_EXIT GPIOD->IDR
#define GPIO_BUTTON_PAGE GPIOD->IDR
#define PIN_BUTTON_PLUS GPIO_Pin_10 //SW3 PE.10
#define PIN_BUTTON_MINUS GPIO_Pin_11 //SW1 PE.12
#define PIN_BUTTON_ENTER GPIO_Pin_12 //SW2 PE.11
+1 -1
View File
@@ -115,7 +115,7 @@ void readKeysAndTrims()
}
}
uint32_t keyState(EnumKeys enuk)
uint32_t switchState(EnumKeys enuk)
{
register uint32_t a = GPIOA->IDR;
register uint32_t b = GPIOB->IDR;
+3 -3
View File
@@ -28,12 +28,12 @@ const uint8_t lcdPalette[4] = { 0, 0x03, 0x06, 0x0F };
void lcdRefresh()
{
for (uint8_t y=0; y<DISPLAY_H; y++) {
uint8_t *p = &displayBuf[(y>>3)*DISPLAY_W];
for (uint8_t y=0; y<LCD_H; y++) {
uint8_t *p = &displayBuf[(y>>3)*LCD_W];
uint8_t mask = (1 << (y%8));
Set_Address(0, y);
AspiCmd(0xAF);
for (uint8_t x=0; x<DISPLAY_W; x+=2) {
for (uint8_t x=0; x<LCD_W; x+=2) {
#if 0
uint8_t data = (p[x] & mask ? 0x80 : 0) + (p[x+1] & mask ? 0x08 : 0) + (p[DISPLAY_PLAN_SIZE+x] & mask ? 0x40 : 0) + (p[DISPLAY_PLAN_SIZE+x+1] & mask ? 0x04 : 0);
#elif 1