Skip to content

Commit ffaee64

Browse files
committed
altos/telelco: Add RSSI display to older devices
Show RSSI value on TeleLCO v2.0 Signed-off-by: Keith Packard <[email protected]>
1 parent 1741039 commit ffaee64

File tree

5 files changed

+48
-22
lines changed

5 files changed

+48
-22
lines changed

src/drivers/ao_lco.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static uint8_t ao_lco_fire_down;
4141
static uint8_t ao_lco_display_mutex;
4242

4343
void
44-
ao_lco_show_pad(uint8_t pad)
44+
ao_lco_show_pad(int8_t pad)
4545
{
4646
ao_mutex_get(&ao_lco_display_mutex);
4747
ao_seven_segment_set(AO_LCO_PAD_DIGIT, (uint8_t) (pad | (ao_lco_drag_race << 4)));
@@ -101,7 +101,7 @@ ao_lco_show(void)
101101
ao_lco_show_voltage(ao_pad_query.battery);
102102
} else {
103103
if (ao_lco_box == AO_LCO_BOX_DRAG)
104-
ao_lco_show_pad(ao_lco_drag_race);
104+
ao_lco_show_pad((int8_t) ao_lco_drag_race);
105105
else
106106
ao_lco_show_pad(ao_lco_pad);
107107
ao_lco_show_box(ao_lco_box);

src/drivers/ao_lco.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ ao_lco_arm_warn(void);
209209
*/
210210

211211
void
212-
ao_lco_show_pad(uint8_t pad);
212+
ao_lco_show_pad(int8_t pad);
213213

214214
void
215215
ao_lco_show_box(int16_t box);

src/drivers/ao_lco_bits.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ ao_lco_search(void)
413413
#ifdef AO_LCO_SEARCH_API
414414
ao_lco_search_box_present(box);
415415
#else
416-
ao_lco_show_pad((uint8_t) (boxes % 10));
416+
ao_lco_show_pad((int8_t) (boxes % 10));
417417
#endif
418418
ao_delay(AO_MS_TO_TICKS(30));
419419
break;

src/drivers/ao_lco_two.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ao_lco_wakeup(void)
4646
}
4747

4848
void
49-
ao_lco_show_pad(uint8_t pad)
49+
ao_lco_show_pad(int8_t pad)
5050
{
5151
(void) pad;
5252
}

src/telelco-v2.0/ao_lco_v2.c

+43-17
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static uint8_t ao_lco_event_debug;
4242
static uint8_t ao_lco_display_mutex;
4343

4444
void
45-
ao_lco_show_pad(uint8_t pad)
45+
ao_lco_show_pad(int8_t pad)
4646
{
4747
ao_mutex_get(&ao_lco_display_mutex);
4848
ao_seven_segment_set(AO_LCO_PAD_DIGIT, (uint8_t) (pad | (ao_lco_drag_race << 4)));
@@ -76,18 +76,31 @@ ao_lco_show_box(int16_t box)
7676
}
7777

7878
static void
79-
ao_lco_show_voltage(uint16_t decivolts)
79+
ao_lco_show_value(uint16_t value, uint8_t point)
8080
{
81-
uint8_t tens, ones, tenths;
81+
uint8_t hundreds, tens, ones;
8282

83-
PRINTD("voltage %d\n", decivolts);
84-
tenths = (uint8_t) (decivolts % 10);
85-
ones = (uint8_t) ((decivolts / 10) % 10);
86-
tens = (uint8_t) ((decivolts / 100) % 10);
83+
PRINTD("value %d\n", value);
84+
ones = (uint8_t) (value % 10);
85+
tens = (uint8_t) ((value / 10) % 10);
86+
hundreds = (uint8_t) ((value / 100) % 10);
87+
switch (point) {
88+
case 2:
89+
hundreds |= 0x10;
90+
break;
91+
case 1:
92+
tens |= 0x10;
93+
break;
94+
case 0:
95+
ones |= 0x10;
96+
break;
97+
default:
98+
break;
99+
}
87100
ao_mutex_get(&ao_lco_display_mutex);
88-
ao_seven_segment_set(AO_LCO_PAD_DIGIT, tenths);
89-
ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, ones | 0x10);
90-
ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, tens);
101+
ao_seven_segment_set(AO_LCO_PAD_DIGIT, ones);
102+
ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, tens);
103+
ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, hundreds);
91104
ao_mutex_put(&ao_lco_display_mutex);
92105
}
93106

@@ -99,19 +112,32 @@ ao_lco_show_lco_voltage(void)
99112

100113
ao_adc_single_get(&packet);
101114
decivolt = ao_battery_decivolt(packet.v_batt);
102-
ao_lco_show_voltage((uint16_t) decivolt);
115+
ao_lco_show_value((uint16_t) decivolt, 1);
103116
}
104117

105118
void
106119
ao_lco_show(void)
107120
{
108-
if (ao_lco_box == AO_LCO_LCO_VOLTAGE) {
121+
switch (ao_lco_box) {
122+
case AO_LCO_LCO_VOLTAGE:
109123
ao_lco_show_lco_voltage();
110-
} else if (ao_lco_pad == AO_LCO_PAD_VOLTAGE) {
111-
ao_lco_show_voltage(ao_pad_query.battery);
112-
} else {
113-
ao_lco_show_pad(ao_lco_pad);
114-
ao_lco_show_box(ao_lco_box);
124+
break;
125+
default:
126+
switch (ao_lco_pad) {
127+
case AO_LCO_PAD_VOLTAGE:
128+
ao_lco_show_value(ao_pad_query.battery, 1);
129+
break;
130+
case AO_LCO_PAD_RSSI:
131+
if (!(ao_lco_valid[ao_lco_box] & AO_LCO_VALID_LAST))
132+
ao_lco_show_value(888, 0);
133+
else
134+
ao_lco_show_value((uint16_t) (-ao_radio_cmac_rssi), 0);
135+
break;
136+
default:
137+
ao_lco_show_pad(ao_lco_pad);
138+
ao_lco_show_box(ao_lco_box);
139+
break;
140+
}
115141
}
116142
}
117143

0 commit comments

Comments
 (0)