Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Semerád Pavel
gt3b
Commits
6f4a5df1
Commit
6f4a5df1
authored
Jun 10, 2011
by
Pavel Semerad
Browse files
added inactivity alarm
parent
051361ce
Changes
9
Hide whitespace changes
Inline
Side-by-side
.depend
View file @
6f4a5df1
...
...
@@ -7,7 +7,7 @@ input.o: input.c input.h gt3b.h stm8.h task.h menu.h \
buzzer.o: buzzer.c buzzer.h gt3b.h stm8.h task.h config.h \
eeprom.h
timer.o: timer.c timer.h gt3b.h stm8.h task.h lcd.h buzzer.h \
input.h menu.h
input.h menu.h
config.h eeprom.h
eeprom.o: eeprom.c eeprom.h config.h gt3b.h stm8.h \
task.h
config.o: config.c config.h gt3b.h stm8.h task.h \
...
...
ChangeLog
View file @
6f4a5df1
...
...
@@ -3,6 +3,8 @@
added 4WS mix
added DIG mix
added steering speed (Turn, Return)
added inactivity alarm
internal changes of trims momentary/opposite_reset
*0.1.0 (2 Jun 2011)
...
...
MANUAL.txt
View file @
6f4a5df1
...
...
@@ -176,6 +176,7 @@ Global setup menu:
- selected menu items are indicated by following symbols:
F firmware version (this of course cannot be changed :-)
L backlight time 5s,10s...10m...MAX
A inactivity alarm OFF,1m...10m
LOW POWER! battery low voltage 7.5...10.5V
E.POINT maximum allowed endpoint value 100...150%
DANGER - values greater than 120% can damage
...
...
TODO
View file @
6f4a5df1
...
...
@@ -2,7 +2,6 @@
Some suggestions taken from manuals of other radios:
timer - up/down/lap/lap navigate - buttons LAP START, LAP RESET
alarm 10min when not used
---
? multi-speed transmission - ability to set exact positions
? CH3-8 position settable from menu
...
...
config.h
View file @
6f4a5df1
...
...
@@ -31,7 +31,7 @@
// change MAGIC number when changing global config
// also add code to setting default values
// 28 bytes
#define CONFIG_GLOBAL_MAGIC 0xf
c03
#define CONFIG_GLOBAL_MAGIC 0xf
b04
typedef
struct
{
u8
steering_dead_zone
;
u8
throttle_dead_zone
;
...
...
@@ -48,7 +48,7 @@ typedef struct {
u16
battery_calib
;
// raw ADC value for 10 Volts
u8
battery_low
;
// low battery threshold in .1 Volts
u8
endpoint_max
;
u
16
inactivity_alarm
;
// time (
sec
) of inactivity warning
u
8
inactivity_alarm
:
4
;
// time (
min
) of inactivity warning
u8
key_beep
:
1
;
}
config_global_s
;
...
...
input.c
View file @
6f4a5df1
...
...
@@ -265,11 +265,11 @@ static void read_keys(void) {
}
// if some of the keys changed, wakeup MENU task
// if some of the keys changed, wakeup MENU task
and reset inactivity timer
if
(
buttons_last
!=
buttons
||
buttons_state_last
!=
buttons_state
)
{
awake
(
MENU
);
reset_inactivity_timer
();
}
}
...
...
@@ -296,6 +296,7 @@ volatile u16 ADC_DB3R @0x53e6;
+ adc_buffer[2][id] + adc_buffer[3][id];
static
void
read_ADC
(
void
)
{
u16
*
buf
=
adc_buffer
[
adc_buffer_pos
];
u8
dead
;
ADC_NEWVAL
(
0
);
ADC_NEWVAL
(
1
);
...
...
@@ -332,9 +333,24 @@ static void read_ADC(void) {
}
}
}
// wakeup task when showing battery or at calibrate
// wakeup MENU task when showing battery or at calibrate
if
(
menu_wants_adc
)
awake
(
MENU
);
// reset inactivity timer when some steering or throttle applied
dead
=
cg
.
steering_dead_zone
;
if
(
dead
<
20
)
dead
=
20
;
// use some minimal dead zone for this check
if
(
adc_steering_last
<
(
cg
.
calib_steering_mid
-
dead
)
||
adc_steering_last
>
(
cg
.
calib_steering_mid
+
dead
))
reset_inactivity_timer
();
else
{
dead
=
cg
.
throttle_dead_zone
;
if
(
dead
<
20
)
dead
=
20
;
// use some minimal dead zone for this check
if
(
adc_throttle_last
<
(
cg
.
calib_throttle_mid
-
dead
)
||
adc_throttle_last
>
(
cg
.
calib_throttle_mid
+
dead
))
reset_inactivity_timer
();
}
}
...
...
menu_global.c
View file @
6f4a5df1
...
...
@@ -110,6 +110,25 @@ static void gs_backlight_time(u8 change) {
}
static
void
gs_inactivity_alarm
(
u8
change
)
{
if
(
change
==
0xff
)
{
lcd_set
(
L7SEG
,
LB_EMPTY
);
return
;
}
if
(
change
)
{
cg
.
inactivity_alarm
=
(
u8
)
menu_change_val
(
cg
.
inactivity_alarm
,
0
,
10
,
1
,
1
);
reset_inactivity_timer
();
}
lcd_7seg
(
L7_A
);
if
(
!
cg
.
inactivity_alarm
)
lcd_chars
(
"OFF"
);
else
{
bl_num2
(
cg
.
inactivity_alarm
);
lcd_char
(
LCHR3
,
'M'
);
}
}
static
void
gs_battery_low
(
u8
change
)
{
u8
*
addr
=
&
cg
.
battery_low
;
if
(
change
==
0xff
)
{
...
...
@@ -227,6 +246,7 @@ typedef void (*global_setup_t)(u8 change);
static
const
global_setup_t
gs_config
[]
=
{
gs_firmware
,
gs_backlight_time
,
gs_inactivity_alarm
,
gs_battery_low
,
gs_endpoint_max
,
gs_steering_dead
,
...
...
timer.c
View file @
6f4a5df1
...
...
@@ -23,6 +23,12 @@
#include "buzzer.h"
#include "input.h"
#include "menu.h"
#include "config.h"
static
u16
inactivity
;
// initialize timer 2 used to count seconds
...
...
@@ -36,6 +42,8 @@ void timer_init(void) {
TIM2_ARRH
=
hi8
(
TIMER_5MS
-
1
);
// count till 5ms time
TIM2_ARRL
=
lo8
(
TIMER_5MS
-
1
);
TIM2_CR1
=
0
b00000101
;
// URS-overflow, enable
inactivity
=
cg
.
inactivity_alarm
*
60
;
}
...
...
@@ -64,6 +72,10 @@ static u16 menu_delay; // timer for delay in MENU task
}
}
// inactivity timer
if
(
inactivity
&&
!
(
--
inactivity
))
buzzer_on
(
20
,
255
,
BUZZER_MAX
);
// expired, buzzer on
}
// lcd blink timer
...
...
@@ -123,3 +135,10 @@ void delay_menu_always(u8 len_s) {
delay_menu
((
to_time
-
time_sec
)
*
200
);
}
// inactivity timer reset
void
reset_inactivity_timer
(
void
)
{
if
(
!
inactivity
)
buzzer_off
();
// stop beeping when applied previously
inactivity
=
cg
.
inactivity_alarm
*
60
;
}
timer.h
View file @
6f4a5df1
...
...
@@ -34,5 +34,9 @@ extern void delay_menu(u16 len_5ms);
extern
void
delay_menu_always
(
u8
len_s
);
// inactivity timer
extern
void
reset_inactivity_timer
(
void
);
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment