LCD/7seg work remotely
This commit is contained in:
parent
4b199e1fb4
commit
1ee1db13a9
5 changed files with 40 additions and 13 deletions
|
|
@ -45,7 +45,7 @@ void init_7seg() {
|
|||
}
|
||||
}
|
||||
|
||||
void decimal_7seg(int module, int value, int dp) {
|
||||
void decimal_7seg(int module, int value, uint8_t dp) {
|
||||
if (value < -9999999 || value > 99999999) {
|
||||
st_7seg.data[module][0] = 0xE;
|
||||
st_7seg.data[module][1] = 16; /* blank */
|
||||
|
|
@ -66,7 +66,7 @@ void decimal_7seg(int module, int value, int dp) {
|
|||
st_7seg.data[module][digit] = r;
|
||||
}
|
||||
|
||||
st_7seg.dp[module] = dp > 0 ? (1<<dp) : 0;
|
||||
st_7seg.dp[module] = dp;
|
||||
}
|
||||
|
||||
void hex_7seg(int module, uint32_t value, uint8_t dp) {
|
||||
|
|
|
|||
26
src/proto.c
26
src/proto.c
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include <proto.h>
|
||||
#include <adc.h>
|
||||
#include <lcd.h>
|
||||
#include <led7seg.h>
|
||||
|
||||
static void tx_time_sync(void);
|
||||
|
|
@ -9,6 +10,7 @@ static void proto_handle_host(bool timeout);
|
|||
static void proto_update_lcd_strings(void);
|
||||
static ErrorCode tx_update_display(void);
|
||||
static void tx_adc_data(void);
|
||||
static void update_displays(struct pkt_update_display *pk);
|
||||
static void tx_button_state(void);
|
||||
|
||||
|
||||
|
|
@ -57,6 +59,7 @@ void uart_handle_user_packet(struct ll_pkt *pkt, size_t len) {
|
|||
|
||||
} else if (board_config == BCFG_DISPLAY) {
|
||||
if (pkt->type == PK_DISPLAY_UPDATE) {
|
||||
update_displays((struct pkt_update_display *)pkt);
|
||||
tx_button_state();
|
||||
}
|
||||
} else if (board_config == BCFG_MEAS) {
|
||||
|
|
@ -110,6 +113,29 @@ void proto_handle_host(bool timeout) {
|
|||
}
|
||||
}
|
||||
|
||||
void update_displays(struct pkt_update_display *pk) {
|
||||
const char *buf[4] = {
|
||||
&pk->lcd[0],
|
||||
&pk->lcd[20],
|
||||
&pk->lcd[40],
|
||||
&pk->lcd[60],
|
||||
};
|
||||
lcd_write_dma(buf);
|
||||
|
||||
for (int module=0; module<3; module++) {
|
||||
int fmt = pk->led_fmt[module];
|
||||
uint8_t dp = (fmt & 0x10) ? (1<<(fmt>>5)) : 0;
|
||||
|
||||
if ((fmt&3) == PROTO_LED_FMT_OFF) {
|
||||
blank_7seg(module);
|
||||
} else if ((fmt&3) == PROTO_LED_FMT_DEC) {
|
||||
decimal_7seg(module, pk->led[module], dp);
|
||||
} else if ((fmt&3) == PROTO_LED_FMT_HEX) {
|
||||
hex_7seg(module, pk->led[module], dp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tx_adc_data() {
|
||||
struct pkt_adc_data pk = {
|
||||
.ll_pkt = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue