show battery voltage
This commit is contained in:
parent
9722873b8f
commit
6c2d82599f
|
@ -18,6 +18,7 @@ set(SOURCES
|
|||
src/main.c
|
||||
src/term.c
|
||||
src/ui.c
|
||||
src/battery.c
|
||||
src/syscalls.S
|
||||
# ...
|
||||
)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#include "battery.h"
|
||||
#include <gint/gint.h>
|
||||
|
||||
extern int _battery(int one);
|
||||
|
||||
static volatile int battery_voltage;
|
||||
static void battery_wrapper(void) { battery_voltage = _battery(1); }
|
||||
|
||||
int get_battery_voltage(void) {
|
||||
gint_world_switch(GINT_CALL(battery_wrapper));
|
||||
return battery_voltage;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef UNS_BATTERY_H
|
||||
#define UNS_BATTERY_H
|
||||
|
||||
int get_battery_voltage(void);
|
||||
|
||||
#endif // #ifndef UNS_BATTERY_H
|
|
@ -61,8 +61,10 @@ int main(void) {
|
|||
char buf[128];
|
||||
sprintf(buf, "tick_ctr=%d key=0x%x mod=%d shift=%d alpha=%d\n", tick_ctr, kev.key, kev.mod, kev.shift, kev.alpha);
|
||||
tgrid_sets(UNS_TERM_ROWS - 2, 0, C_WHITE, C_BLACK, buf);
|
||||
set_statusbar(tick_ctr, shift_state, alpha_state);
|
||||
|
||||
set_statusbar(tick_ctr, shift_state, alpha_state, get_battery_voltage());
|
||||
set_menubar();
|
||||
|
||||
tgrid_display();
|
||||
|
||||
tick_ctr++;
|
||||
|
|
4
src/ui.c
4
src/ui.c
|
@ -6,7 +6,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void set_statusbar(int tick_ctr, int shift_state, int alpha_state) {
|
||||
void set_statusbar(int tick_ctr, int shift_state, int alpha_state, int battery) {
|
||||
// set green bar
|
||||
for (int i = 0; i < UNS_TERM_COLS; i++)
|
||||
tgrid_sets(0, i, C_NONE, C_GREEN, " ");
|
||||
|
@ -16,7 +16,7 @@ void set_statusbar(int tick_ctr, int shift_state, int alpha_state) {
|
|||
|
||||
// then add actutal text
|
||||
char statusbar[UNS_TERM_COLS + 1];
|
||||
sprintf(statusbar, "%s %s t=%d", shift_symbol, alpha_symbol, tick_ctr);
|
||||
sprintf(statusbar, "%s %s t=%d, bat=%d% cV", shift_symbol, alpha_symbol, tick_ctr, battery);
|
||||
tgrid_sets(0, 0, C_BLACK, C_GREEN, statusbar);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue