summaryrefslogtreecommitdiff
path: root/fw/fe310/test/test.c
blob: 9cf7605804a1cdeb37e1df2143c970393015ca60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <eos.h>
#include <i2c.h>
#include <i2c/bq25895.h>
#include <eve/eve.h>
#include <eve/eve_kbd.h>
#include <eve/eve_font.h>

#include <eve/screen/window.h>
#include <eve/screen/page.h>
#include <eve/screen/form.h>

#include <eve/widget/widgets.h>

#include <app/app_root.h>

#include <board.h>

#include "test.h"

#include <stdio.h>

static int reg_read(uint8_t reg, uint8_t *data) {
    return eos_i2c_read8(BQ25895_ADDR, reg, data, 1);
}

static int reg_write(uint8_t reg, uint8_t data) {
    return eos_i2c_write8(BQ25895_ADDR, reg, &data, 1);
}

int app_test_uievt(EVEForm *form, uint16_t evt, void *param) {
    uint8_t data = 0;
    int rv, ret = 0, i;

    switch (evt) {
        case EVE_UIEVT_PAGE_TOUCH:
            printf("PAGE TOUCH\n");
            printf("BQ25895:\n");
            eos_i2c_start();
            for (i=0; i<0x15; i++) {
                rv = reg_read(i, &data);
                if (!rv) printf("REG%02x: %02x\n", i, data);
            }
            eos_i2c_stop();
            break;

        default:
            ret = eve_form_uievt(form, evt, param);
            break;
    }
    return ret;
}

void app_test(EVEWindow *window, EVEViewStack *stack) {
    EVEWidgetSpec spec[] = {
        {
            .widget.type = EVE_WIDGET_TYPE_SPACER,
            .widget.g.h = 1,
        },
    };
    EVEForm *form = eve_form_create(window, stack, spec, 1, app_test_uievt, NULL, app_test_close);
}

void app_test_close(EVEForm *form) {
    eve_form_destroy(form);
}