added % to submenus, removed leaved lcd segments in trim_sualrate(), repair reading more keys pressed together and trim reset

This commit is contained in:
Pavel Semerad
2011-05-16 22:00:01 +02:00
parent a5618b2a93
commit 8deca35a2f
4 changed files with 37 additions and 10 deletions

13
input.c
View File

@@ -57,10 +57,10 @@ void input_init(void) {
// buttons
IO_OPF(B, 4); // button row B4
IO_OPF(B, 5); // button row B5
IO_OPF(C, 4); // button row C4
IO_OPF(D, 3); // button row D3
IO_OOF(B, 4); // button row B4
IO_OOF(B, 5); // button row B5
IO_OOF(C, 4); // button row C4
IO_OOF(D, 3); // button row D3
IO_IP(C, 5); // button col C5
IO_IP(C, 6); // button col C6
IO_IP(C, 7); // button col C7
@@ -117,6 +117,9 @@ void button_reset(u16 btn) {
buttons &= ~btn;
buttons_long &= ~btn;
}
void button_reset_nolong(u16 btn) {
buttons &= ~btn;
}
// set autorepeat
@@ -307,7 +310,7 @@ static void read_ADC(void) {
+ adc_battery_last;
adc_battery = (u16)((adc_battery_filt + (ADC_BAT_FILT / 2)) / ADC_BAT_FILT);
// start checking battery after 5s from power on
if (time_sec < 5) {
if (time_sec >= 5) {
// wakeup task only when something changed
if (adc_battery > 50 && adc_battery < battery_low_raw) {
// bat low

View File

@@ -78,6 +78,7 @@ extern volatile u16 adc_battery_last;
extern void button_reset(u16 btn);
#define btnr(mask) button_reset(mask)
#define btnra() button_reset(BTN_ALL)
extern void button_reset_nolong(u16 btn);
// set autorepeat

25
menu.c
View File

@@ -526,12 +526,19 @@ static void trim_dualrate(u8 menu, u8 channel, s8 *val, u16 btn_l, u16 btn_r,
// show MENU and CHANNEL
lcd_segment(menu, LS_ON);
lcd_segment(LS_SYM_MODELNO, LS_OFF);
lcd_segment(LS_SYM_DOT, LS_OFF);
lcd_segment(LS_SYM_VOLTS, LS_OFF);
lcd_segment(LS_SYM_CHANNEL, LS_ON);
lcd_7seg(channel);
while (1) {
// check value left/right
if (btn(btn_l | btn_r)) {
if (btnl(btn_l | btn_r)) {
// reset to 0
*val = 0;
btnr(btn_l | btn_r);
}
else if (btn(btn_l | btn_r)) {
key_beep();
if (btn(btn_l)) {
*val -= step;
@@ -541,7 +548,7 @@ static void trim_dualrate(u8 menu, u8 channel, s8 *val, u16 btn_l, u16 btn_r,
*val += step;
if (*val > max) *val = max;
}
btnr(btn_l | btn_r);
button_reset_nolong(btn_l | btn_r); // waiting for possible 0-set
}
// show current value
@@ -560,6 +567,8 @@ static void trim_dualrate(u8 menu, u8 channel, s8 *val, u16 btn_l, u16 btn_r,
if (!buttons) break;
}
btnr(btn_l | btn_r); // reset also long values
// set selected MENU off
lcd_segment(menu, LS_OFF);
@@ -963,8 +972,10 @@ void sf_endpoint(u8 channel, u8 change) {
if (change) *addr = (u8)menu_change_val(*addr, 0, cg.endpoint_max, 5);
lcd_char_num3(*addr);
}
@inline static void menu_endpoint(void) {
static void menu_endpoint(void) {
lcd_segment(LS_SYM_PERCENT, LS_ON);
menu_channel(MAX_CHANNELS, 1, sf_endpoint);
lcd_segment(LS_SYM_PERCENT, LS_OFF);
}
// set trims
@@ -997,8 +1008,10 @@ static void sf_dualrate(u8 channel, u8 change) {
if (change) *addr = (u8)menu_change_val(*addr, 0, 100, 5);
lcd_char_num3(*addr);
}
@inline static void menu_dualrate(void) {
static void menu_dualrate(void) {
lcd_segment(LS_SYM_PERCENT, LS_ON);
menu_channel(2, 0, sf_dualrate);
lcd_segment(LS_SYM_PERCENT, LS_OFF);
}
// set expos
@@ -1007,8 +1020,10 @@ static void sf_expo(u8 channel, u8 change) {
if (change) *addr = (s8)menu_change_val(*addr, -99, 99, 5);
lcd_char_num2(*addr);
}
@inline static void menu_expo(void) {
static void menu_expo(void) {
lcd_segment(LS_SYM_PERCENT, LS_ON);
menu_channel(3, 0, sf_expo);
lcd_segment(LS_SYM_PERCENT, LS_OFF);
}
// set abs

8
stm8.h
View File

@@ -62,10 +62,18 @@ typedef unsigned long u32;
BSET(P ## port ## _DDR, pin); \
BSET(P ## port ## _CR1, pin); \
BRES(P ## port ## _CR2, pin)
#define IO_OO(port, pin) \
BSET(P ## port ## _DDR, pin); \
BRES(P ## port ## _CR1, pin); \
BRES(P ## port ## _CR2, pin)
#define IO_OPF(port, pin) \
BSET(P ## port ## _DDR, pin); \
BSET(P ## port ## _CR1, pin); \
BSET(P ## port ## _CR2, pin)
#define IO_OOF(port, pin) \
BSET(P ## port ## _DDR, pin); \
BRES(P ## port ## _CR1, pin); \
BSET(P ## port ## _CR2, pin)
#endif